简体   繁体   English

如何从默认浏览器获取URL以在自定义浏览器中使用?

[英]How can I get the URL from the default browser to use in my custom browser?

I am developing an Android app in which a type of browser will be included. 我正在开发一个Android应用,其中将包含一种浏览器。 As the user tries to open a URL, an intent resolver asks the user whether they want to complete the action using the default browser or a custom browser. 当用户尝试打开URL时,意图解析器会询问用户是否要使用默认浏览器或自定义浏览器来完成操作。 This part of my app is completed. 我的应用程序的这一部分已完成。 Now I want to ask, if the user chooses to open the link in my custom browser, how can I access that URL? 现在,我想问一问,如果用户选择在自定义浏览器中打开链接,我该如何访问该URL?

Currently, if the user chooses my browser they got blank web view, as I am unable to get the URL which I have to open in my webview. 当前,如果用户选择我的浏览器,他们将获得空白的Web视图,因为我无法获取必须在Web视图中打开的URL。

If the user chooses to open the link in my custom browser, how can I access that URL? 如果用户选择在自定义浏览器中打开链接,我如何访问该URL?

Call getIntent().getData() to get the Uri the user is trying to open. 调用getIntent().getData()以获取用户尝试打开的Uri

如果您的自定义浏览器是针对某个意图而启动的,则目标URL应包含在该意图中以供您提取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM