Android 点击链接启动APP

在参与项目过程,客户提出要像Iphone那样,通过点击邮件里面的连接来启动APP:

起初在网上不断的search,找到了两个比较有用的回答:

http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser

http://stackoverflow.com/questions/3469908/make-a-link-in-the-android-browser-start-up-my-app

总结了一下,解决方案如下:

1.

需要在点击链接时,启动的Activity下添加下面的filter

            <intent-filter>  
                 
                <action android:name="android.intent.action.VIEW" />    
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE"></category>    
                <!-- 指定启动APP的schema和host,强烈建议使用http等公开的schema,自定义的schema可能无法被邮件等视为超链接 -->
                <data android:scheme="http" android:host="bizconf.mobile.com" />              
            </intent-filter>

然后我们就可以在邮件等内容中发送超链接

http://bizconf.mobile.com/xxxx


点击链接后,就会弹出让我们选择哪个程序启动(一般是浏览器和我们自己的程序),点击我们的程序启动就OK了。


2.点击链接时,获取链接中附带的数据:

http://twitter.com/status/1234:

Uri data = getIntent().getData();
String scheme = data.getScheme(); // "http"
String host = data.getHost(); // "twitter.com"
List<String> params = data.getPathSegments();
String first = params.get(0); // "status"
String second = params.get(1); // "1234"
如果大家有其他好的实现方法,欢迎分享~


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值