创建一个应用程序,在应用程序的AndroidManifest.xml文件中配置:
<activity
android:name="com.lxq.myapp2.SecondActivity">
<intent-filter >
<action android:name="android.intent.action.VIEW"/>
<!-- 定义该activity支援的浏览模式 -->
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<!-- 定义要处理的url scheme -->
<data android:scheme="myapp2"/>
</intent-filter>
</activity>
SecondActivity是通过url打开程序后进入的界面
myapp2是定义的scheme
通过url打开本应用程序,url是myapp2://a?SID=hello,我来自MyApp2
如果想添加点击后选择是应用程序打开还是浏览器打开,data修改如下:
<data android:scheme="http"
android:host="myapp2"/>
打开的url改为:http://myapp2,这里我没有加传递的参数,有兴趣的朋友可以添加一下。
这里提一下,这是本人写完案例之后想记录下来的东东,以便以后查找
参考过的文章:http://blog.youkuaiyun.com/favormm/article/details/6623490
http://www.dotblogs.com.tw/pou/archive/2012/01/01/64089.aspx
案例下载地址:http://download.youkuaiyun.com/detail/snow_sun_li/6663931