문제

I would like to define my own "SetupWizard" application. To do so, I am using 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 don't know how to tell that the Wizard is over. For now, it is just looping after my last finish() call.

How can I tell it ?

Tkx.

도움이 되었습니까?

해결책

For a 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 do to disable itself once finished. You need the CHANGE_COMPONENT_ENABLED_STATE permission.

My wizard activity has the following in AndroidManifest.xml:

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

다른 팁

for a custom ROM do the following:
e.g. 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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top