(go) Launch a third-party apk app from an android apk

Source: Internet
Author: User

Launch a third-party apk app from Android apk

We are in the development, often encounter in an apk to run another apk, just like our windows, to make a shortcut like, how to do it?

The core of the problem is that we have to get the third-party APK package name and class name, both of which are critical! For example, I do test QQ apk,package name is Com.tencent.pad.qq,class name is com.tencent.pad.qq.login.QQLoginActivity. Booting from one apk to another apk, of course, is also done by sending intent. Here are a few simple steps:

1, in order to intuitive or build an icon is better. ImageButton controls are available on Android. It is defined in XML as follows:

[HTML]View Plaincopy
    1. <ImageButton android:id="@+id/startqq"
    2. android:layout_width="85dip"
    3. android:layout_height="54dip"
    4. android:layout_margintop="20dip" />

2, register the message processing function. That is, when you click on the icon, what to do to respond. The registration code is as follows:

[Java]View Plaincopy
    1. private ImageButton Mstartqqbutton;
    2. Mstartqqbutton = (ImageButton) Findviewbyid (R.ID.STARTQQ);
    3. Mstartqqbutton.setonclicklistener (Mstartqqlistener);

3, prepare intent, send intent. The code is as follows:

[Java]View Plaincopy
  1. Private View.onclicklistener Mstartqqlistener = new View.onclicklistener () {
  2. public void OnClick (View v) {
  3. if (localService = = null) return;
  4. Localservice.reqmusicexit ();
  5. Intent mintent = new Intent ();
  6. ComponentName comp = new ComponentName ("Com.tencent.pad.qq", "com.tencent.pad.qq.login.QQLoginActivity"  );
  7. Mintent.setcomponent (comp);
  8. Mintent.setaction ("Android.intent.action.VIEW");
  9. StartActivity (mintent);
  10. Finish ();
  11. }
  12. };

This is just an example, mastered this method, we can develop a similar Windows shortcut icon bar, it can be arbitrary, to develop products that customers like. By the way, I would like to say, this approach must be in the code of the APK application to customize, such as in the launcher, or the development of their own apk.

(go) Launch a third-party apk app from an android apk

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.