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