Android-从网站检查Chrome应用是否具有存储权限 [英] Android - check from web site if Chrome app has storage permission

查看:177
本文介绍了Android-从网站检查Chrome应用是否具有存储权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前用户从我的网站下载APK.但是,某些用户没有将Chrome授予存储访问权限,因此会出现此错误:

Currently users download an APK from my site. However, some users didn't give access to Chrome to Storage so they get this error:

因此用户需要向Chrome授予存储权限.

So users need to give Storage permission to Chrome.

我的问题是,如果 Chrome 具有该权限,是否可以在用户单击以下载APK(例如,使用JavaScript)之前进行检查,如果没有,请指示用户该怎么做.

My question is whether I can check before the user click to download the APK (for example, with JavaScript), if Chrome has that permission, and if not instruct the user what he should do.

推荐答案

我会说你不能这样做.

首先,让我们看一下Chrome android应用程序如何检查是否已授予存储空间.

First, let's look at how the Chrome android application check if the storage is granted.

您可以使用诸如jadx-gui之类的工具来查看chrome应用程序的代码,然后在其内部搜索权限检查.在这里,我们对"WRITE_EXTERNAL_STORAGE"感兴趣,您可以看到在DownloadController类中检查了此权限,阅读了一下该类的工作原理后,我们首先了解到什么时候想要下载任何文件并想要保存它.他们检查是否授予了许可,如果没有,则会显示一个警告对话框(您在问题中显示的对话框).

You can use some tools such as jadx-gui to see the code of the chrome application, inside it, search for permission checking. Here we are interested in "WRITE_EXTERNAL_STORAGE", you can see that this permission is checked inside the DownloadController class, reading a bit how this class work allow us to understand that when something want to download any file, and want to save it, first they check if the permission is granted, if it is not, they display an alert dialog (the one you showed in your question).

与此相关的问题是,如果没有任何接口设置,则使用JavaScript不能与chrome应用程序内部的方法进行交互.

The problem with this, is that with JavaScript you cannot interact with methods inside the chrome application if they are not any interface setup.

您能做的最好的事情是在用户下载应用程序之前在您的网站上发布一条消息.尝试找出适用于Chrome android应用程序的解决方案不是一个好主意,因为对于其他任何网络浏览器来说,这都是非常困难且毫无意义的,因为它们都以不同的方式管理权限(例如存储).

The best thing you can do is to put a message on your website before the user download the application. Trying to figure out a solution for the Chrome android application is not a good idea because that would be very difficult and pointless for any other web browser, because they all manage permission (such as storage) in different way.

这篇关于Android-从网站检查Chrome应用是否具有存储权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆