Android launches its own apk from a third party

Source: Internet
Author: User

This article is mainly after reading the Guo Lin in an article after the experiment

Post the Great God's article address: http://mp.weixin.qq.com/s?__biz=MzA5MzI3NjE2MA==&mid=2650235870&idx=1&sn= 8499e45b52199e739d73ba7d2db2c21b&scene=0#wechat_redirect

Talking about the connection from the Web to open their own applications, thinking of using a mobile phone to build a server, using Ksweb Open source server, helpless no success.

1. Launch another apk with APK: (two separate apps)

The code primarily requires the full package name and full class name of the app to be launched, passing the message by sending intent

Launching another app from one app requires the package name with the class name        Intent mintent = new Intent ();        Mintent.addflags (intent.flag_activity_new_task);        ComponentName comp = new ComponentName ("Com.cl.slack.deeplinks", "com.cl.slack.deeplinks.MainActivity");        Mintent.setcomponent (comp);        Mintent.setaction ("Android.intent.action.VIEW");        StartActivity (mintent);        Finish ();

2. To oneself is also drunk, finally incredibly uses Tomcat to build a LAN server, and then the virtual machine to open the LAN address, haha, but I also realized the function of the great God, in the Web page to open their own app



The Web end is a word

<a href= "com.slack.androidtest://buydress" >deep link</a>
Manifest file:
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" Android.addre.com.deeplinks "> <application android:allowbackup=" true "Android : icon= "@mipmap/ic_launcher" android:label= "@string/app_name" android:supportsrtl= "true" Android:theme = "@style/apptheme" > <activity android:name= ". Mainactivity "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/&                Gt <category android:name= "Android.intent.category.LAUNCHER"/>//Deep links <action  Android:name= "Android.intent.action.VIEW"/> <category android:name= "Android.intent.category.DEFAULT" /> <category android:name= "Android.intent.category.BROWSABLE"/> <data android: Scheme= "Com.slack.androidtest"/> </intent-filter> </Activity> <activity android:name= ". Buyactivity "> </activity> </application></manifest>
Activity initiated by default:

/** Deep Links * Reference Guo Lin article: http://mp.weixin.qq.com/s?__biz=MzA5MzI3NjE2MA==&mid=2650235870&idx=1&sn= 8499e45b52199e739d73ba7d2db2c21b&scene=0#wechat_redirect * Create by chenling 2016-05-10 * */public class Mainactivity extends Appcompatactivity {@Override protected void onCreate (Bundle savedinstancestate) {Super        . OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_main);        Intent Intent = Getintent ();            if (intent! = null) {URI uri = Intent.getdata ();                if (uri! = null) {//URI com.slack.androidtest://buydress log.i ("Slack", uri.tostring ());                String host = Uri.gethost ();                LOG.I ("slack", host); if ("Buydress". Equals (host)) {//jump to sell Skirt interface startactivity (new Intent (this,buyactivity                . Class)); }            }        }    }}
Thank you, Guo Lin, great God.


Android launches its own apk from a third party

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.