In this code:
c.startActivity(selector);
p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
when you call startActivity()
, the activity isn't started immediately. What this does is just tell the Android framework that you would like to start another activity at the next possible time that the framework gets control. In the next line you disable the component so that when the Android framework goes to start the activity, your launcher component has been disabled again.
The call to startActivity()
is not synchronous.