Android One app activity invokes another app's activity

Source: Internet
Author: User

Learned the call of activity between two applications , and method calls between two applications (implemented using aidl )

Two applications are as follows : from application, to application ( from activity Call to application activity)

Implementation method:

1. Declare the activity of the to application to be invoked in the from manifest file

<application android:allowbackup= "true" android:icon= "@drawable/ic_launcher "Android:label=" @string/app_name "android:theme=" @style/apptheme "> <activity Andro                Id:name= "com.example.from.MainActivity" android:label= "@string/app_name" > <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category android:name= "Androi D.intent.category.launcher "/> </intent-filter> </activity> <activity android:n Ame= "Com.example.to.ToActivity" > <intent-filter> <action android:name= "Android.inte Nt.action.VIEW "> </action> <category android:name=" Android.intent.category.DEFA ULT "> </category> </intent-filter> </activity> </application& gt; 

2. The code that is called in the activity is as follows

             ComponentName componetname = new ComponentName (  //This is another application's package name  "Com.example.to",  //This parameter is the activity to start  "com.example.to.ToActivity");  try {  Intent Intent = new Intent ();  Intent.setaction ("Android.intent.action.VIEW");//bundle bundle = new Bundle ();//bundle.putcharsequencearray ("Val", New string[]{"111", "222", "333", "444"});//intent.putextras (bundle);//Bind bundle data//intent.setcomponent ( Componetname); StartActivity (intent);  } catch (Exception e) {toast.maketext (Getapplicationcontext (), "You can prompt the user not to find the application, or to do other things! ", 0). Show ();  LOG.V ("Go to apk Error", "------>" +e.tostring ());}  

Since we are calling the to application from the From app, we also need to set the properties for the activity to be called in the to application, as follows:

  <activity android:name= "com.example.to.ToActivity"            android:exported= "true" >               </activity>




Android One app activity invokes another app's activity

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.