[英]android intent-filter <data> is not working correctly
I am trying to have my application intercept on a specific URL in browser. 我试图让我的应用程序拦截浏览器中的特定URL。 following is my code in the Manifest: 以下是我在Manifest中的代码:
<activity
android:name="com.myactivity.RootActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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" />
<data android:host="subdomian.maindomain.com" />
</intent-filter>
</activity>
it is working fine at the moment, when I open the link http://subdomain.maindomain.com/ , a dialog comes up with my activity listed on it. 它现在工作正常,当我打开链接http://subdomain.maindomain.com/时 ,会出现一个对话框,其中列出了我的活动。
but when I add android:path
in the intent-filter like below, it stops working, it doesn't even work with simple url without the path. 但是当我在如下面的intent-filter中添加android:path
时,它会停止工作,它甚至不能使用没有路径的简单URL。
<activity
android:name="com.myactivity.RootActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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" />
<data android:host="subdomian.maindomain.com" />
<data android:path="myPath" />
</intent-filter>
</activity>
am I doing something wrong here? 我在这里做错了吗?
I tested what you said using these links and its working for me 我用这些链接测试了你所说的内容,并为我工作
<data android:scheme="http" />
<data android:host="developer.android.com" />
<data android:path="/guide/topics/manifest/data-element.html"/>
And the intent i used is 我使用的意图是
Intent browserIntent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://developer.android.com/guide/topics/manifest/data-element.html"));
startActivity(browserIntent);
The android:path
must match after the host url that you gave for it to work ? android:path
必须匹配你给它的主机网址才能工作? Can you specify what URL did you use ? 你能指定你使用的URL吗? Read this link for help 阅读此链接以获取帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.