工厂测试应用的总结

经过昨天一天的猛虎操作,终于工厂的需求进入尾声,总结下新学到的知识

如果想让两个apk 预置在launcher 需要修改launcher 的配置文件
配置如下 packages/apps/Launcher3/res/xml/default_workspace_4x4.xml


<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3">

    <!-- Hotseat -->
    <include launcher:workspace="@xml/dw_phone_hotseat" />

    <favorite
        launcher:packageName=""    //包名
        launcher:className="Activity" //带包名的activity
        launcher:screen="0"  //第几屏
        launcher:x="0"   //x位置
        launcher:y="3" />  //y的位置
    <favorite
        launcher:packageName=""
        launcher:className="Activity"
        launcher:screen="0"
        launcher:x="1"
        launcher:y="3" />

</favorites>

这样点击就能进入app的activity 但是我还没有找到单编 launcher3的方法,所以直接增量编译

这两个工厂测试的app 可以通过dial secret code 进入 其实就是发送一个广播
AndroidManifest.xml 需要配置 广播接收者

        <receiver
            android:name=".BroadcastReceiver">
            <intent-filter>
                <action
                    android:name="android.provider.Telephony.SECRET_CODE" />
                <data
                    android:scheme="android_secret_code"
                    android:host="64542552" />  
            </intent-filter>
        </receiver>

上面配置的其实就是网址 格式,可以通过getIntent 获取相关信息

        <activity
            android:name=".LauncherActivity"
            android:label="@string/cit_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Holo.Light">
            <intent-filter>
                <action
                    android:name="android.intent.action.MAIN" />
                <category
                    android:name="android.intent.category.DEFAULT" />
                <category
                    android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

启动的activity 一定要有 action :android.intent.category.LAUNCHER 这个决定点击应用进入的activity 界面

activity 启动模式有四种 standard 、single top、single instance、SingleTask
如果想集中管理activity 就要在application中 进行操作

public class TestApplication extends Application {
    private List<Activity> mList = new ArrayList<>();
    private static CitApplication instance;
    public CitApplication(){}//注意这里的构造函数一定是public 不能private 

    public static synchronized TestApplication getInstance(){
        if (null == instance){
            instance = new TestApplication();
        }
        return instance;
    }

    public void addActivity(Activity activity){ //添加activity 实例
        mList.add(activity);
    }

    public void removeActivity(){ //销毁activity 实例
        for(Activity activity:mList){
            if (activity != null){
                activity.finish();
            }
        }
    }
}

7

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值