android - 使用权限后的 SecurityException

标签 android security permissions securityexception

我的应用程序出现严重问题。我使用权限 android.permission.ACCESS_COARSE_LOCATION在广播接收器中,它运行完美。

但是在一定时间后(这似乎是随机的)应用程序崩溃并显示以下输出:

SecurityException neither user 10086 nor current process has permission android.permission.ACCESS_COARSE_LOCATION

我已使用 <uses-permission etc /> 将权限包含在 list 中并试图在我 sendOrderedBroadcast 时使其更具体我也广播了许可,并已将许可授予广播接收器,以便它可以接收广播。

但就像我说的,过了一会儿,SecurityException 在代码的第二行被抛出:

TelephonyManager Tel = (TelephonyManager) vb.getPsrC()
            .getSystemService(Activity.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation) Tel.getCellLocation();

这次崩溃似乎只发生在运行 Froyo 的测试设备上。

在运行 Gingerbread 的设备上,该应用程序只是使用较少的内存重新启动服务而不执行任何操作。这些问题是相关的还是安全异常与应用程序崩溃互斥。

最佳答案

好的,原来罪魁祸首是内存泄漏。当 GREF 达到 2001 时,它崩溃并基本上清空了它(因为缺少更好的短语)导致应用程序认为未授予权限。我修复了将 phonelistener 移动到服务中的问题。

关于android - 使用权限后的 SecurityException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8322844/

相关文章:

C++ 安全异常处理

Android Marshmallow 权限测试

mysql - 授予用户权限以仅查看 MySQL View 而不是其他 View

sql-server - 以另一个用户身份执行存储过程

android - 字符串到 XML Android

android - 使用目标 GL_TEXTURE_2D 在纹理上渲染相机预览

javascript - 如何让 Google Tag Manager 和 Content-Security-Policy 共存?

使用 ssl 形式的 WordPress 让我们加密,但主页并不完全安全。 "Attackers might be able to see images.."消息

android - npx react-native run-android : E/Device: Error during Sync: EOF

java - 是否可以在 @BeforeClass 注释方法中运行 Android Espresso 单元测试?