沧海一粟

----not just a programmer

导航

android 定义 程序 Scheme 接收特定URI开启Activity

场景:通过浏览器打开URL或者扫描软件扫描URL来启动本地应用

<intent-filter>
                <category android:name="android.intent.category.DEFAULT"></category>
                <action android:name="android.intent.action.VIEW"></action>
                <data android:scheme="sh"></data>
            </intent-filter>

这样即指定了接收Uri的Scheme为sh 且 Action为View的Intent。

利用如下Intent调用Activity

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("sh://123123123")));

在接收的Activity中使用如下代码获得数据

this.getIntent().getScheme();//获得Scheme名称
this.getIntent().getDataString();//获得Uri全部路径

 

posted on 2015-07-26 17:33  沧海一粟-啊添  阅读(2717)  评论(0编辑  收藏  举报