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

来源:互联网 发布:印度同志聊天软件 编辑:程序博客网 时间:2024/05/01 12:08
首先在AndroidManifast.xml要被指定Scheme的Activity下设置如下参数

[html] view plain copy
  1. <intent-filter>  
  2.                 <category android:name="android.intent.category.DEFAULT"></category>  
  3.                 <action android:name="android.intent.action.VIEW"></action>  
  4.                 <data android:scheme="sh"></data>  
  5.             </intent-filter>  

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


利用如下Intent调用Activity

[java] view plain copy
  1. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("sh://123123123")));  

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

[java] view plain copy
  1. this.getIntent().getScheme();//获得Scheme名称  
  2. this.getIntent().getDataString();//获得Uri全部路径  
0 0
原创粉丝点击