Android开发中应用选择器中没有自己的应用的解决方案(网页浏览器)

针对网页浏览器(Action.View)的方法

AndroidManifest.xmlWebActivity下添加intent-filter

正常的intent-filter是这样的:

<intent-filter tools:ignore="AppLinkUrlError">
  <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"/>
</intent-filter>

但是某些奇怪的情况下并不会显示我们的应用。
于是需要添加其他的intent-filter确保所有情况下我们的应用都会显示出来。

具体添加内容如下:

<intent-filter tools:ignore="AppLinkUrlError">
	<action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

<intent-filter>
	<action android:name="android.intent.action.PROCESS_TEXT" />
	<category android:name="android.intent.category.DEFAULT" />
	<data android:mimeType="text/plain" />
</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:scheme="https" />
	<data android:scheme="about" />
	<data android:scheme="ucweb" />
	<data android:scheme="javascript" />
</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="ut.21711551" />
</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:host="com.UCMobile"
	    android:path="/open_my_video_window"
	    android:scheme="flyme_3dtouch"
	    tools:ignore="AppLinkUrlError" />
	<data
	    android:host="com.UCMobile"
	    android:path="/open_info_flow_channel_window"
	    android:scheme="flyme_3dtouch"
	    tools:ignore="AppLinkUrlError" />
	<data
	    android:host="com.UCMobile"
	    android:path="/open_novel_bookshelf_window"
	    android:scheme="flyme_3dtouch"
	    tools:ignore="AppLinkUrlError" />
</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:host="www.uc.cn"
	    android:pathPrefix="/cc77796ca7c25dff9607d31b29effc07"
	    android:scheme="uclink" />
</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:host="details"
	    android:scheme="market" />
</intent-filter>

<intent-filter
tools:ignore="AppLinkUrlError">
	<action android:name="android.intent.action.VIEW" />
	<category android:name="android.intent.category.DEFAULT" />
	<category android:name="android.intent.category.BROWSABLE" />
	<data android:mimeType="text/html" />
	<data android:mimeType="text/xml" />
	<data android:mimeType="application/xhtml+xml" />
	<data android:mimeType="application/vnd.wap.xhtml+xml" />
</intent-filter>

<intent-filter>
	<action android:name="android.intent.action.WEB_SEARCH" />
	<action android:name="android.intent.action.SEARCH" />
	<category android:name="android.intent.category.DEFAULT" />
	<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

<intent-filter>
	<action android:name="android.intent.action.WEB_SEARCH" />
	<action android:name="android.intent.action.SEARCH" />
	<category android:name="android.intent.category.DEFAULT" />
	<category android:name="android.intent.category.BROWSABLE" />
	<data android:scheme="http" />
	<data android:scheme="https" />
	<data android:scheme="about" />
	<data android:scheme="ucweb" />
	<data android:scheme="javascript" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.LOADURL" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.WEBSEARCH" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.LOADBUFFER" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.INVOKE" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.OPENFILEMANAGER" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.OPENVIDEO" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.BARCODESCAN" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="com.UCMobile.intent.action.NOTIFICATION_TOOL_SETTING" />
	<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<intent-filter>
	<action android:name="android.net.http.NETWORK_STATE" />
	<action android:name="android.intent.action.PROXY_CHANGE" />
</intent-filter>

<intent-filter>
	<category android:name="android.intent.category.DEFAULT" />
	<category android:name="android.intent.category.BROWSABLE" />
	<action android:name="android.intent.action.VIEW" />
	<data android:scheme="file" />
	<data android:scheme="content" />
	<data android:scheme="ucweb" />
	<data android:mimeType="text/html" />
	<data android:mimeType="text/xml" />
	<data android:mimeType="application/xhtml+xml" />
	<data android:mimeType="application/vnd.wap.xhtml+xml" />
	<data android:mimeType="text/css" />
</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="ftp" />
	<data android:scheme="thunder" />
	<data android:scheme="ed2k" />
	<data android:scheme="flashget" />
	<data android:scheme="magnet" />
</intent-filter>

<intent-filter>
	<action android:name="android.intent.action.VIEW" />
	<category android:name="android.intent.category.BROWSABLE" />
	<category android:name="android.intent.category.DEFAULT" />
	<data android:scheme="file"
	    tools:ignore="AppLinkUrlError" />
	<data android:scheme="content" />
	<data android:mimeType="application/x-bttorrent" />
	<data android:pathPattern=".*.torrent" />
</intent-filter>
原文地址:https://www.cnblogs.com/kujisa/p/13072803.html