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

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

http://blog.csdn.net/csy172775922/article/details/6821651

原创 2011年09月26日 12:15:05

 


首先在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全部路径  


 

 

 
posted @ 2018-03-03 14:24  sky20080101  阅读(101)  评论(0)    收藏  举报