权限拒绝:不从uid导出从null(pid = -1,uid = 10221)开始的Intent [英] Permission Denial: starting Intent from null (pid=-1, uid=10221) not exported from uid

查看:455
本文介绍了权限拒绝:不从uid导出从null(pid = -1,uid = 10221)开始的Intent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种情况:

服务正在运行.该服务具有一个计时器,该计时器会定期对服务器进行http调用以搜索数据.该数据已由其他用户存储在DB中.当该数据可用时,将解析来自服务器的答案,并显示一条通知.当用户点击通知时,活动将启动...直到昨天.我正在使用Eclipse,它是接收数据的用户的真实设备,而发送数据的用户的虚拟设备.

A Service is running. This service has a timer that does an http call to a server periodically in search for data. That data has been stored in DB by other user. When that data is available, the answer from the server is parsed, and a notification is shown. When the user taps the notification, an Activity is launched...until yesterday. I am using Eclipse, a real device for the user that receives the data, and a virtual device for the user that sends the data.

当用户点击通知时,活动未启动,这很奇怪,因为正如我所说,活动一直持续到昨天.在Logcat中,我有这个:

When the user taps the notification, the Activity is not launched, what is weird, because it was working until yesterday, as I said. In the Logcat I have this:

05-05 23:12:36.841: W/ActivityManager(1029): Permission Denial: starting Intent { cmp=my.package/.CalledFromNotificationActivity bnds=[0,538][540,632] (has extras) } from null (pid=-1, uid=10221) not exported from uid 10242
05-05 23:12:36.851: W/ActivityManager(1029): Unable to send startActivity intent
05-05 23:12:36.851: W/ActivityManager(1029): java.lang.SecurityException: Permission Denial: starting Intent { cmp=my.package/.CalledFromNotificationActivity bnds=[0,538][540,632] (has extras) } from null (pid=-1, uid=10221) not exported from uid 10242
05-05 23:12:36.851: W/ActivityManager(1029):    at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1215)
05-05 23:12:36.851: W/ActivityManager(1029):    at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:747)
05-05 23:12:36.851: W/ActivityManager(1029):    at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:3372)
05-05 23:12:36.851: W/ActivityManager(1029):    at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:252)
05-05 23:12:36.851: W/ActivityManager(1029):    at com.android.server.am.PendingIntentRecord.send(PendingIntentRecord.java:192)
05-05 23:12:36.851: W/ActivityManager(1029):    at android.content.IIntentSender$Stub.onTransact(IIntentSender.java:64)
05-05 23:12:36.851: W/ActivityManager(1029):    at android.os.Binder.execTransact(Binder.java:404)
05-05 23:12:36.851: W/ActivityManager(1029):    at dalvik.system.NativeStart.run(Native Method)

这是启动Intent的代码:

This is the code that launches the Intent:

Intent intent=new Intent(c, CalledFromNotificationActivity.class);
Bundle bundle=new bundle();
bundle.setString("somedata", somedata);
intent.putExtras(bundle);
PendingIntent pIntent=PendingIntent.getActivity(c, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);                           
                        Builder notif = new NotificationCompat.Builder(c);
                        synchronized (notif) {

                                    notif.setContentIntent(pIntent)
                                            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                                            .setWhen(System.currentTimeMillis())
                                            .setTicker("Notification ticker")
                                            .setSmallIcon(R.drawable.ic_launcher)
                                            .setContentTitle(getString(R.string.app_name))
                                            .setContentText(getString(R.string.text))
                                            .setAutoCancel(true);

                                    Notification notification = notif.build();
                                      //get instance of NotificationManager
                                      NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

                                      notificationmanager.notify(0, notification);
                                     timer.cancel();
                            }

我已阅读到清单文件中的Activity声明中添加android:exported="true"可以解决该问题,但是我不愿意使用它,因为显然不是我的预期用途.

I have read that adding android:exported="true" in the Activity declaration in the Manifest file could solve it, but I am reluctant to use it, since clearly is not the intended use in my case.

我认为pid中可能是-1 ...但是我不知道为什么是-1以及如何解决它.

I think it might be that -1 in the pid...but I don't know why is -1 and how to solve it.

有人可以帮我吗?

谢谢.

推荐答案

我遇到了同样的问题,这是Kitkat的问题,我从

I got the same problem, it is Kitkat's issue, i got the workround solution from here. you can try it like this:

PendingIntent pIntent = PendingIntent.getActivity(c, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);  
        if (Build.VERSION.SDK_INT == 19) {
            contentIntent.cancel();
            pIntent = PendingIntent.getActivity(c, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        }

对我有用,希望有用.

这篇关于权限拒绝:不从uid导出从null(pid = -1,uid = 10221)开始的Intent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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