- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
使用 NotificationManagerCompat
取消所有通知。
NotificationManagerCompat manager =
NotificationManagerCompat.from(ctx.getApplicationContext());
manager.cancelAll();
它有时会出现异常(大部分时间都有效)。
在安卓 6 上:
java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=22994, uid=10184 requires android.permission.INTERACT_ACROSS_USERS
Fatal Exception: java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=22994, uid=10184 requires android.permission.INTERACT_ACROSS_USERS
at android.os.Parcel.readException(Parcel.java:1602)
at android.os.Parcel.readException(Parcel.java:1555)
at android.app.INotificationManager$Stub$Proxy.cancelAllNotifications(INotificationManager.java:649)
at android.app.NotificationManager.cancelAll(NotificationManager.java:323)
at android.support.v4.app.NotificationManagerCompat.cancelAll(NotificationManagerCompat.java:197)
在 Android 5.0、4.4.2 上:
ava.lang.SecurityException: Permission Denial: getIntentSender() from pid=5460, uid=10135, (need uid=1000) is not allowed to send as package android at android.os.Parcel.readException(Parcel.java:1465)
Fatal Exception: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=3109, uid=10153, (need uid=1000) is not allowed to send as package android
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.app.INotificationManager$Stub$Proxy.cancelAllNotifications(INotificationManager.java:271)
at android.app.NotificationManager.cancelAll(NotificationManager.java:220)
at android.support.v4.app.NotificationManagerCompat.cancelAll(NotificationManagerCompat.java:197)
问题:
ctx.getApplicationContext().getApplicationInfo().uid
还是 android.os.Process.myUid()
?最佳答案
答案并没有为问题提供可靠的解决方案,而是试图解释 OP 和 @66CLSjY 的原因。 ,谁提供了赏金,similar issue .
检查堆栈跟踪
根据堆栈跟踪 SecurityException
在远程进程中抛出:您的应用进程的 Binder
对象(例如 INotificationManager.Stub
、ActivityManagerProxy
等)makes a Binder
transaction (mRemote.transact()
) * 在远程 Binder
对象上并从对象中读取发生的异常 (_reply.readException()
)远程调用。如果有的话,exception message is analyzed and a corresponding exception is thrown在你的过程中。
分析异常消息
两个异常消息(一个带有 getIntentSender()
和另一个带有 getCurrentUser()
的消息)都非常简单 - 您的应用没有通过权限检查,或者换句话说,ActivityManagerService 的代码 fragment
under the
(system_server
process' identity 的UID=1000
) **,但实际上被称为 under your app process' identity .
可能的原因和解决方法
It got exception some time (most time works).
不做任何假设,你得到的“一段时间”是不正确的Android
行为。 Wrapping the problem call with try/catch
在有人提出可靠的解决方案(如果存在)之前,这似乎是一种解决方法。
* ActivityManagerProxy.setRequestedOrientation()和 IAccessibilityManager$Stub$Proxy.sendAccessibilityEvent()
** android.permission.INTERACT_ACROSS_USERS
是 signature | system protection level
关于android - 为什么 NotificationManagerCompat::cancelAll() 得到 SecurityException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36634008/
我正在编写一个 C# 程序(具体来说是一个 IRC 机器人)并使用脚本库 Jint ( http://jint.codeplex.com/ )。我有一个外部命令链接到它,当调用它时,它会从另一个文件读
我有一个具有外部 API 的服务。在某些情况下我必须抛出 SecurityException。奇怪的事情如下:在某些 API 中,当我抛出异常时,绑定(bind)器成功完成此事务并且该异常被服务的经理
我有一个用 C# 编写的应用程序,它位于网络共享上。当我从本地驱动器运行它时,一切正常。当我从远程共享启动它时,调用像 try { System.Reflection.Assembly.Get
如果我自己的 DAO 类无法通过数据存储的身份验证,是否建议在其构造函数中抛出 SecurityException? Java 文档说 SecurityException 将由 SecurityMan
背景 我正在开发一款控制屏幕旋转的 Android 应用。 The app is available on the Google Play store .为了控制屏幕旋转,应用程序禁用了 system
这个问题在这里已经有了答案: Permission Denial: not allowed to send broadcast in android (4 个答案) 关闭 9 年前。 我的应用程序在
我尝试将位置服务作为后台服务运行。它在 Activity 中运行良好,但是当我使用服务时,我得到了 java.lang.securityException:客户端必须具有 ACCESS_COARSE_
我做了一个方法,当进度完成加载时发送本地通知,当我构建应用程序时,一切都清楚,没有任何错误/警告,我在发布 Google 控制台崩溃报告后收到了这个 通知方式如下: public void notif
我正在编写一个 Android 应用程序,作为该应用程序的一部分,我希望用户能够查看、选择和修改用户联系人。出于可用性原因(从用户方面),我的主要 Activity 扩展了 TabActivity。因
我在我的应用程序中使用带指纹的锁屏。虽然它可以与其他具有指纹传感器的手机无缝协作,但三星用户正面临一些 SecurityException,正如我在我的谷歌控制台报告中看到的那样。报告如下: java
我想制作一个能够将文件下载到计算机的小程序,然后在相关的编辑器中打开它们(当文件被保存时,应该会再次上传)。然而,在我花几个小时让它工作之前,我必须确保它实际上是可管理的(用 Java 桌面应用程序而
我的应用程序出现严重问题。我使用权限 android.permission.ACCESS_COARSE_LOCATION在广播接收器中,它运行完美。 但是在一定时间后(这似乎是随机的)应用程序崩溃并显
我在某些 API 6.0+ 设备上遇到以下崩溃: Fatal Exception: java.lang.SecurityException: Client must have ACCESS_COARS
我正在试验 Android AccountManager。 我有一个帐户身份验证服务,显示用于输入用户名/密码的 UI。 我转到设置/帐户/添加帐户,选择我的新帐户类型,然后我会看到 UI。 当我点击
使用此代码时出现上述错误: var userSettings = new UserSettings() { Username = TextBox
我似乎无法在 .NET 中写入事件日志。我得到以下异常: System.Security.SecurityException: The source was not found, but some o
我设计了一个函数,它可以从 SD 获取/设置资源,如果从 sd 中找不到,则从 Asset 中获取它,如果可能,将 Assets 写回 SD 此函数可以通过方法调用检查 SD 是否已安装且可访问...
FileStream 的 MSDN 构造函数表示它可能会抛出 UnauthorizedAccessException 或 SecurityException。以下是 MSDN 关于这些异常的说明。 U
我正在使用 Retrofit 的协程适配器,我发现,如果网络调用因为 URL 不正确而失败,则 try/catch block 将捕获它,但如果我删除 Internet 权限以便我们得到 Securi
我刚刚编写了一个 MVC 应用程序并让它在我的实验室中运行。现在我已将其部署到 GoDaddy,但收到以下错误。 Description: The application attempted to p
我是一名优秀的程序员,十分优秀!