Summary of factory test application

After yesterday's tiger operation, the demand of the factory finally came to an end, and the new knowledge was summed up

If you want to preset two apk s in the launcher, you need to modify the configuration file of the launcher
Configure packages / apps / launcher3 / RES / XML / default workspace / 4x4.xml as follows

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

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

    <favorite
        launcher:packageName=""    //Package name
        launcher:className="Activity" //Packet nameactivity
        launcher:screen="0"  //The first few screens
        launcher:x="0"   //xposition
        launcher:y="3" />  //Location of y
    <favorite
        launcher:packageName=""
        launcher:className="Activity"
        launcher:screen="0"
        launcher:x="1"
        launcher:y="3" />

</favorites>

In this way, you can click to enter the activity of app, but I haven't found a way to compile launcher3 separately, so I just need to do incremental compilation

The app tested by these two factories can be accessed through dial secret code, which is actually to send a broadcast
Android manifest.xml needs to configure the broadcast receiver

        <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>

The above configuration is actually the URL format. You can get relevant information through 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>

The activity to be started must have action: android.intent.category.LAUNCHER, which determines the activity interface to be entered by clicking the application

There are four activation modes: standard, single top, single instance and SingleTask
If you want to manage activities centrally, you need to operate in application

public class TestApplication extends Application {
    private List<Activity> mList = new ArrayList<>();
    private static CitApplication instance;
    public CitApplication(){}//Note that the constructor here must be public, not private 

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

    public void addActivity(Activity activity){ //Add activity instance
        mList.add(activity);
    }

    public void removeActivity(){ //Destroy activity instance
        for(Activity activity:mList){
            if (activity != null){
                activity.finish();
            }
        }
    }
}

7

Tags: Android xml

Posted on Sun, 09 Feb 2020 09:33:31 -0800 by Ramtree