Missing URL error on VIEW Intent filter if I speci

2020-07-13 11:06发布

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.

2条回答
冷血范
2楼-- · 2020-07-13 11:22

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.

查看更多
狗以群分
3楼-- · 2020-07-13 11:27

@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.

查看更多
登录 后发表回答