Android: Launch additional apps and pass parameters

Source: Internet
Author: User

Reprinted from: http://blog.csdn.net/iefreer/article/details/8812585

Sometimes you need to launch another app from one app, such as twitter/.

If you do not know the activity of the app, but know the package name, then you can use the following method:

[Java]View Plaincopy
    1. Intent launchintent = Getpackagemanager (). Getlaunchintentforpackage ("com.package.address");
    2. StartActivity (launchintent);


If there is a partnership between apps, you can get a manifest file for the Affiliate app (manifest), you can learn about package/activity from this file,
You can use the following method to launch the app-specific activity interface:

[Java]View Plaincopy < param name= "allowfullscreen" value= "false" >< param name= "wmode" value= "Transparent" >
    1. Intent Intent = new Intent (Intent.action_main);
    2. Intent.setcomponent (new ComponentName ("com.package.address","com.package.address.MainActivity"));
    3. StartActivity (Intent);


If you want to pass parameters when you start the app, you can set it in intent (Intent):

[PHP]View Plaincopy
    1. Intent.putextra ("Firstkeyname","Firstkeyvalue");
    2. Intent.putextra ("Secondkeyname","Secondkeyvalue");

Reference Links:

Http://developer.android.com/guide/components/intents-filters.html

Android: Launch additional apps and transfer parameters (GO)

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.