Original: Android Project Combat (22): Launch another app or restart the app
First, launch another app
Current company project needs, a main app, need to open some small apps, these small apps are integrated unity, but still Android program (all small app package name is known).
Did not do before, query the implementation method, in fact, is quite simple, testing can also.
The code is relatively simple, directly affixed to:
Try { = getactivity (). Getpackagemanager (); Intent Intent=new Intent (); = Packagemanager.getlaunchintentforpackage ("com.maiji.textviewchangedemo"); Here the parameter is the package name of the app you want to open startactivity ( intent); Catch (Exception e) { log.e (" Error opening another application ", E.getmessage ()); is not open, the app you might want to open is not installed and needs to be processed again }
2. Restart the app
This feature is relatively rare, in the QQ set font size will restart the app
Code:
Intent Intent = getbasecontext (). Getpackagemanager () . Getlaunchintentforpackage (Getbasecontext (). Getpackagename ()); Intent.addflags (intent.flag_activity_clear_top); StartActivity (intent);
Android Project Combat (22): Launch another app or restart the app