1

当用户在浏览器中选择磁力链接时,我想从我的应用程序启动 Android 活动。

根据文档

URI 由每个部分的单独属性指定:
scheme://host:port/path 或 pathPrefix 或 pathPattern

磁铁链接的问题在于它们具有不同的模式,例如magnet:?xt=......

我尝试过这样的事情

<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="magnet"
        android:host="*"
    />
</intent-filter>

但它不起作用(当我在浏览器中打开磁力链接时,活动没有启动)。你能帮我正确地为磁铁链接声明一个意图过滤器吗?

4

1 回答 1

1

我得到这个为我工作:

<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="magnet"
    />
</intent-filter>

基本上,我删除了android:host

于 2012-08-14T08:35:14.517 回答