Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何拦截特定url上的点击并打开自己的webclient——Android_Android_Hyperlink_Android Webview - Fatal编程技术网

如何拦截特定url上的点击并打开自己的webclient——Android

如何拦截特定url上的点击并打开自己的webclient——Android,android,hyperlink,android-webview,Android,Hyperlink,Android Webview,我正在聊天,在此聊天中,一些消息将链接到特定的url(此url将在服务器中打开文档查看器) 链接如下所示:http://X.X.X.X:8080/DocumentViewer/... 然后我有一个webview活动,我想在这里打开这种类型的链接 当用户单击此类链接时,如何“拦截”并打开我自己的webview而不打开“外部”浏览器?我认为您可以通过在您感兴趣的URL模式的AndroidManifest.xml文件中创建意图过滤器来实现这一点。intent过滤器元素的文档显示了如何指定主机和方案(“

我正在聊天,在此聊天中,一些消息将链接到特定的url(此url将在服务器中打开文档查看器)

链接如下所示:
http://X.X.X.X:8080/DocumentViewer/...

然后我有一个webview活动,我想在这里打开这种类型的链接


当用户单击此类链接时,如何“拦截”并打开我自己的webview而不打开“外部”浏览器?

我认为您可以通过在您感兴趣的URL模式的
AndroidManifest.xml文件中创建
意图过滤器来实现这一点。
intent过滤器
元素的文档显示了如何指定
主机
方案
(“html”)来处理URL

答案显示了一个开发人员希望处理youtube.com URL的示例。为了完整起见,我将清单片段包括在下面:

<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.youtube.com" android:scheme="http" />
</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="http://X.X.X.X:8080/DocumentViewer/" android:scheme="http" />
</intent-filter>

我认为您可以通过在
AndroidManifest.xml
文件中为您感兴趣的URL模式创建一个
intent过滤器来实现这一点。
intent过滤器
元素的文档显示了如何指定
主机
方案
(“html”)来处理URL

答案显示了一个开发人员希望处理youtube.com URL的示例。为了完整起见,我将清单片段包括在下面:

<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.youtube.com" android:scheme="http" />
</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="http://X.X.X.X:8080/DocumentViewer/" android:scheme="http" />
</intent-filter>


您是否使用列表视图显示您的对话?如果是,它可能很难看,但您可以在ListView上设置一个侦听器并解析消息……您是否使用ListView显示您的对话?如果是,它可能很难看,但您可以在ListView上设置一个侦听器并解析消息。。。