4

我有一些关于权限和提示的问题。最重要的是,这与建立数据连接和使用 GPS 有关

问题

1. 提示和允许 - 删除通知?:在各种设备上安装我的应用程序(已签名)时,有些设备会提示用户建立数据连接,有些则不会(刚刚建立连接)。我检查了权限,并在两台设备上将它们的数据连接设置为提示。为什么一个设备只是建立连接而另一个需要提示?注意:两个设备都在同一个运营商(版本)上,并且不受 BES 限制。

2. 最近构建中的预授权对话框:在最近构建中,提示用户允许数据请求。在以前的版本构建中,这个提示从未发生过(即使两个构建都建立了可能需要提示的数据连接)。对于我的一生,我无法说出我可能有什么变化导致现在出现的提示。我应该在构建/项目/文件中检查什么,这样这些提示就不会再出现了吗?

3. 安装时设置权限?:有没有办法在安装应用程序时强制执行权限(比如允许)?我知道我可以做 invokePermissionsRequest 但这会在运行应用程序时发生。理想情况下,我希望在没有用户参与或安装期间解决权限问题。

需要注意的一些事实:

  • 为 4.2.1 及更高版本开发
  • 应用已签名
  • 应用程序使用数据连接和 GPS
4

3 回答 3

0

关于问题#3,如果您的程序设置为启动时自动运行,它将在安装时运行。这就是应用程序和/或库在安装时与系统挂钩的方式。重新启动时需要小心,因为系统总是可能会决定升级需要重新启动,在这种情况下,您的代码将在重新启动过程的后期运行,但在 UI 可用之前。所以这段代码需要检查权限是否正确。如果没有,请延迟到 UI 运行(如果尚未运行),然后进行调用以提示更改。

于 2010-02-20T00:25:10.880 回答
0

Pertaining to your questions #1 and #2... There may be differences in behavior depending on what OS the device is using. Many permissions were modified/renamed/created when OS 4.7 was released. For example, here are the permissions I request for OS 4.5:

ApplicationPermissions.PERMISSION_FILE_API
ApplicationPermissions.PERMISSION_INTER_PROCESS_COMMUNUCATION
ApplicationPermissions.PERMISSION_CHANGE_DEVICE_SETTINGS
ApplicationPermissions.PERMISSION_EXTERNAL_CONNECTIONS
ApplicationPermissions.PERMISSION_INTERNAL_CONNECTIONS
ApplicationPermissions.PERMISSION_WIFI
ApplicationPermissions.PERMISSION_EMAIL
ApplicationPermissions.PERMISSION_HANDHELD_KEYSTORE

And here are the permissions I request for OS 4.7:

ApplicationPermissions.PERMISSION_FILE_API
ApplicationPermissions.PERMISSION_CROSS_APPLICATION_COMMUNICATION
ApplicationPermissions.PERMISSION_DEVICE_SETTINGS
ApplicationPermissions.PERMISSION_INTERNET
ApplicationPermissions.PERMISSION_SERVER_NETWORK
ApplicationPermissions.PERMISSION_WIFI
ApplicationPermissions.PERMISSION_EMAIL
ApplicationPermissions.PERMISSION_SECURITY_DATA,     

You can see that a number of permissions were renamed. You may need to update your code to be aware of the OS and request specific permissions.

For question #3, there is no way to execute any kind of code on-install. The best you can do is make your application 'Auto-run on startup' and perform the check then. However, this might be a worse solution, as the user may become confused by getting a permissions request dialog on startup.

The best solution is to make sure you have sufficient privileges every time your application is launched. If not, request all necessary privileges and handle everything as gracefully as possible. If you execute this successfully, your users will only have to deal with the permissions the very first time your application is launched (as long as they don't mess around with them on their own later on).

于 2010-01-18T17:00:47.483 回答
0

问题 #1。检查您是否启用了防火墙。选项->安全选项->防火墙。如果已启用,则在尝试访问 GPS 时会提示您,如果未启用,则不会提示您。

问题2。这可能与您应用的先前版本的状态有关。如果您在现有应用程序的顶部安装,黑莓将“记住”它已经询问过您的提示以及您的答案是什么。另一方面,如果您在安装前卸载,黑莓将“被遗忘”。

问题 #3。安装时无法运行自定义代码。

于 2010-02-19T22:17:13.560 回答