I have this scenario:
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.
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)
This is the code that launches the Intent:
Intent intent=new Intent(c, CalledFromNotificationActivity.class);
Bundle bundle=new bundle();
bundle.setString("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();
}
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.
I think it might be that -1 in the pid...but I don't know why is -1 and how to solve it.
Could anyone help me please?
Thank you.
Aucun commentaire:
Enregistrer un commentaire