通过外部连接代开本地app_Android配置及注意事项

来源:互联网 发布:韩服lol翻译软件 编辑:程序博客网 时间:2024/06/06 00:27

自己推算,我们只需配置下环境

需要在要启动的页面中配置意图过滤就可以

            <intent-filter>                <action android:name="android.intent.action.VIEW"/>                <category android:name="android.intent.category.DEFAULT" />                <category android:name="android.intent.category.BROWSABLE" />                <data                    android:host="my.com"                    android:scheme="sciencechina" />            </intent-filter>

注:scheme中不要有大写字母   这样大概该页面的超链接就是:
sciencechina://my.com/ 我们在浏览器中输入这个也可以提示打开
//<a href="[scheme]://[host]/[path]?[query]">启动应用程序</a> 

//如果需要传输数据的话

path:传值时必须的key     ※没有也可以

query:获取值的Key和Value  ※没有也可以

Intent i_getvalue = getIntent();  
String action = i_getvalue.getAction();   
if(Intent.ACTION_VIEW.equals(action)){  
    Uri uri = i_getvalue.getData();  
    if(uri != null){  
        String name = uri.getQueryParameter("name");  
        String age= uri.getQueryParameter("age");  
    }  
}
?UC,猎豹,欧朋这三款浏览器不支持

0 0
原创粉丝点击