小编sab*_*aba的帖子

中断我的应用程序的链接

我有个问题.我正在使用以下代码来中断我的应用程序的链接

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="http" android:host="twitter.com"/>
    <data android:scheme="http" android:host="facebook.com"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

但问题是我需要在运行时设置数据方案和主机,即我可以在运行时添加或删除主机.如何在运行时设置数据方案和主机的值?我使用下面的代码,但它无法正常工作

IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.VIEW");
filter.addCategory("android.intent.category.DEFAULT");
filter.addCategory("android.intent.category.BROWSABLE");
filter.addDataScheme("http");
filter.addDataAuthority("www.facebook.com", null);
RecieveBroadcaster  receiver = new RecieveBroadcaster();
registerReceiver(receiver, filter);
Run Code Online (Sandbox Code Playgroud)

android

7
推荐指数
1
解决办法
1489
查看次数

标签 统计

android ×1