Missing URL error on VIEW Intent filter if I specify mimeType for action PICK

六月ゝ 毕业季﹏ 提交于 2019-12-23 03:21:42

问题


I have an app that could view different kinds of video files using intent filters from different sources. To allow the app to appears always as choice when I try to open whatever video file, I have placed this code in the manifest

<intent-filter>
  <action android:name="android.intent.action.VIEW"/>
  <action android:name="android.intent.action.PICK"/>
  <data android:mimeType="video/*" />
</intent-filter>

So I can receive the Uri in the app handling It in the main activity.

Although everything seems working as supposed, every time that I try to edit the manifest Android Studio marks all intent filter code with a red underline reporting the error missing url. The error disappears If I remove <data android:mimeType="video/*" /> but If I do this the app appears as choice not only for video files.


回答1:


@AndreaF I have tha same issue. You can just suppress this warning.

To suppress try this:

<intent-filter tools:ignore="AppLinkUrlError">
  <action android:name="android.intent.action.VIEW"/>
  <action android:name="android.intent.action.PICK"/>
  <data android:mimeType="video/*" />
</intent-filter>

add xmlns:tools="http://schemas.android.com/tools" to your initial manifest tag if it's not already there.




回答2:


Prompt missing url not because action.PICK, the error related to action.VIEW

<intent-filter>
  <action android:name="android.intent.action.VIEW"/>  //delete this line
  <action android:name="android.intent.action.PICK"/>
  <category android:name="android.intent.category.DEFAULT"/>  //add this line
  <category android:name="android.intent.category.OPENABLE"/> //and this
  <data android:mimeType="video/*" />
</intent-filter>

for action.VIEW,you could define a different intent-filter.



来源:https://stackoverflow.com/questions/52506871/missing-url-error-on-view-intent-filter-if-i-specify-mimetype-for-action-pick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!