Next, let's talk about a perfect solution.
Because the first interface is the Welcome interface, the shortcut startup interface is also welcome, and at first you suspect that the code created by the shortcut is problematic, but you don't know what the problem is. Guessing may be a shortcut to the error caused the system to create two applications, it is also the same application will have two PID, the results in the console to view the print log, the different ways to start log as follows:
Copy Code code as follows:
09-22 09:39:11.929:info/activitymanager (%): starting:intent {act=android.intent.action.main cat=[ Android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.xxx/.activity. Initactivity} from PID 19304
09-22 09:39:12.876:info/activitymanager (): Displayed com.android.xxx/.activity. Initactivity: +763ms
09-22 09:39:47.668:info/activitymanager (%): starting:intent {act=android.intent.action.main flg=0x10000000 cmp= Com.android.xxx/.activity. Initactivity bnds=[5,392][115,510]} from PID 19304
09-22 09:39:48.737:info/activitymanager (): Displayed com.android.xxx/.activity. Initactivity: +995ms
Finally found two PID is consistent (Initactivity is the Welcome interface activity), may be an accident, the two log comparisons will find that from the list click on the icon to start the application is the above log, through the shortcut to boot is the following log, through the comparison will find that, Starting an application with a shortcut is less cat=[android.intent.category.launcher than the other way around], so add in your code (refer to the previous code and add only the third row):
Copy Code code as follows:
ComponentName comp = new ComponentName (This.getpackagename (), this.getpackagename () + "." +this.getlocalclassname ());
Intent Intent = new Intent (intent.action_main). SetComponent (comp);
Intent.addcategory (Intent.category_launcher);
Shortcut.putextra (Intent.extra_shortcut_intent, Intent);
Again run application all OK, will not start two applications, exit also only need once, too to force! As for why it is left to the spectators you.