User Activity on First Start (Initialization Wizard)

I would like to define my own SetupWizard application. For this, I use this intent filter and it works fine:

<intent-filter android:priority="5"> <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> 

However, I do not know how to say that the Master is finished. For now, this is just a loop after my last completion ().

How can I say that?

Tkx

+4
source share
2 answers

For the custom ROM, I did something like this after setting up the user:

 PackageManager pm = getPackageManager(); pm.setComponentEnabledSetting(new ComponentName("com.domain.yourapp", "com.domain.yourapp.SetupWizardActivity"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); 

This is what the CM setup wizard does to shutdown after completion. You need permission CHANGE_COMPONENT_ENABLED_STATE.

The activity of my wizard in AndroidManifest.xml has the following meanings:

 <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> 
+5
source

for custom ROM follow these steps:
for example, in your onPause () or any other trigger method, do something like:

 // set DEVICE_PROVISIONED flag because we will end setup wizard and our application. Settings.Secure.putInt(getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 1); // enable quicksettings Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1); // remove your activity from package manager final ComponentName yourActivityCompName = new ComponentName(this, yourSetupWizardClass.class); final PackageManager packageMngr = getPackageManager(); try { packageMngr.setComponentEnabledSetting(yourActivityCompName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); } catch (IllegalArgumentException illArgExcp) { Log.d(TAG, "IllegalArgumentException: The package name or/and class name you try to remove is not available"); } finish(); 
0
source

Source: https://habr.com/ru/post/1496762/


All Articles