In your app's androidmanifest.xml, make the following changes to the startup page
< Intent-filter > < android:name= "Android.intent.action.MAIN"/> < android:name= "Android.intent.category.DEFAULT"/> </ intent-filter>
In a third-party program, call the following
New Intent (Intent.action_main); Intent.setcomponent (new componentname ("Com.test.app", "com.test.app.MainActivity")); Intent.addflags (Intent.flag_activity_new_task); StartActivity (intent) ;
Where Com.test.app is the application package name, and Com.test.app.MainActivity is the first activity you want to start, that is, the start page referred to above
If you do not know the startup page, or your startup page will change, you can also call the following
Public BooleanstartApp (String packagename) {Intent Intent=NewIntent (Intent.action_main,NULL); Intent.addcategory (Intent.category_default); Packagemanager pm=Getpackagemanager (); List<ResolveInfo> Listinfos = pm.queryintentactivities (Intent, 0); String ClassName=NULL; for(ResolveInfo info:listinfos) {if(Packagename.equals (info.activityInfo.packageName)) {ClassName=Info.activityInfo.name; Break; } } if(ClassName! =NULL&& classname.length () > 0) {intent.setcomponent (Newcomponentname (PackageName, className)); Intent.setflags (Intent.flag_activity_new_task|intent.flag_activity_reset_task_if_needed); StartActivity (Intent); return true; } return false; }
Android How to Do app icon Hide, launched by a third party program