6

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.

g123k
  • 3,748
  • 6
  • 42
  • 45
  • Make 2nd activity as your main activity and call SetupWizard activity for the first time – Tarun Aug 13 '13 at 10:16
  • This is already the case, the Activity receiving the Intent just launches the 2nd Activity – g123k Aug 13 '13 at 11:36
  • WHat I said was to make setupwizard as your second activity and launch it only for the first time. i.e dont make it your MAIN activity. – Tarun Aug 13 '13 at 11:45

2 Answers2

6

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" />
Alex
  • 2,893
  • 25
  • 24
1

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();
digitalxm
  • 61
  • 1
  • 6