简体   繁体   English

android-在不通过意图的情况下从应用程序打开Chrome的任何方法? 镀铬方案?

[英]android- any way to open chrome from the app without passing an intent? chrome scheme?

The situation I have now is that I have an app built with webview which is pointing to my website. 现在的情况是我有一个使用webview构建的应用程序,该应用程序指向我的网站。 I never had any file for user to download on my site, so I never take care of onDownloadStart . 我从来没有任何文件可供用户下载到我的网站上,因此我从不会照顾onDownloadStart here comes an issue when I recently upload a file to my site and let user to download it. 当我最近将文件上传到我的站点并允许用户下载它时,这里出现一个问题。 Users are not able to download the file if they are inside of the app. 如果用户在应用程序内部,则他们将无法下载文件。 I can however set the downloadlistsner but people with older version are hopeless. 但是,我可以设置downloadlistsner但是使用较旧版本的人绝望了。 I then came up with an idea to send user to chrome. 然后,我想到了将用户发送到chrome的想法。 but throwing out an intent for chrome to catch isn't available yet in the app with older version. 但是在旧版本的应用程序中尚无法抛出chrome捕获的意图。 the only place I can make this happen is update my site. 我唯一能做到这一点的地方就是更新我的网站。 Is it possible that I can do something like chrome://url=blahblah and have chrome to take care of the url? 是否可以执行chrome://url=blahblah并让chrome处理该url? or is there any better way to solve this issue? 还是有解决这个问题的更好方法?

Thanks guys 多谢你们

You could use the intent: scheme , and specify the Chrome activity as the target, however this will only work if the user has Chrome installed. 您可以使用intent:scheme ,并将Chrome活动指定为目标,但是只有在用户安装了Chrome的情况下,此方法才有效。

Also, whether this works or not depends how you implemented WebViewClient.shouldOverrideUrlLoading: 另外,这是否有效取决于您如何实现WebViewClient.shouldOverrideUrlLoading:

  • if you didn't set a WebViewClient at all, then it's fine, 如果您根本没有设置WebViewClient,那就可以了,
  • otherwise you would need code in shouldOverrideUrlLoading that would create an Intent ( something similar to this ). 否则,您将需要在ShouldOverrideUrlLoading中创建可创建Intent的代码( 类似于this )。

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

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