Android Project Combat (22): Launch another app or restart the app

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.