Because the development needs to package an app, so to launch an app, this operation if you know the package name and class name is actually very simple only need to embed the package name (in general, we can decompress or reverse access)
The code is as follows:
Intent Intent = new Intent (intent.action_main);
Set the package name and class name ComponentName Mcomponentname = new ComponentName ("Com.kukum.mynews", "com.kukum.android.SplashActivity"); Intent.setcomponent (Mcomponentname); StartActivity (Intent);
But if you do not know the class name, you need to get the package information based on the package name and then get the startup class to jump code as follows
Create a class with the same package name Category_launcher intentintent resolveintent = new Intent (intent.action_main, NULL); Resolveintent.addcategory (Intent.category_launcher); Resolveintent.setpackage ("com.kukum.mynews");// Traverse list<resolveinfo> resolveinfolist = GetPackageManager () through the Queryintentactivities method of the Getpackagemanager () . Queryintentactivities (resolveintent, 0);//Because there is a category and action associated so the startup class has only one if there is a startup class Resolveinfo Resolveinfo = Resolveinfolist.iterator (). Next (); if (resolveinfo! = null) {String className = resolveinfo.activityinfo.name;intent Intent = new Intent (Intent.action_main); intent.addcategory (Intent.category_launcher); ComponentName mcomponentname = new ComponentName ("Com.kukum.mynews", ClassName); Intent.setcomponent (Mcomponentname) ; StartActivity (intent);}
Get
App launches other apps