网页启动Android APK

点击网页中的URL链接,打开手机中已经存在的Android应用。

网页中URL格式:

打开app

例:打开app

scheme:启动app的标识,必须有;

host:有无不影响启动;

path:有无不影响启动;

query:获取值的key和value,有无不影响启动。


Android端,在AndroidManifest.xml中的MainActivity的注册信息中添加如下代码

         

         

         

         

                    android:scheme="cbg" 

                    android:host="android"/>

:新添加的的内容不可也原有的的内容混合在一个中,要使用两个


数据传递:

使用URL添加参数的方式

如:打开app


Android端获取数据

Intent intent = getIntent();

String page,num;

Uri uri = intent.getData();

if(uri!=null){

      page=uri.getQueryParameter("page");

      num=uri.getQueryParameter("num")

}


相关链接:

http://stackoverflow.com/questions/3469908/make-a-link-in-the-android-browser-start-up-my-app

http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser

你可能感兴趣的:(网页启动Android APK)