Reputation: 17
I am really stcuk. The code below, works when I try to start an activity in one application while it generates a canceled exception when I try to start an activity in another application. I have searched for potential solutions including
Notification pendingIntent contentIntent fails when activity calls finish()
I also looked at the PendingIntent.java source code. The canceled exception is called when
" * @throws CanceledException Throws CanceledException if the PendingIntent * is no longer allowing more intents to be sent through it. "
Below, you will find my code. I would appreciate any advice/pointers towards a solution of this problem.
Thanks,
Alex Donnini
private static Intent intentForMainActivityFromNetGuard = new Intent();
private static PendingIntent pendingIntent;
PREPARE TO START MainActivityFromNetGuard - START
intentForMainActivityFromNetGuard = new Intent();
intentForMainActivityFromNetGuard.setComponent(new ComponentName("ca.uwaterloo.crysp.privacyguard", "ca.uwaterloo.crysp.privacyguard.Application.Activities.ActivityMainFromNetGuard"));
intentForMainActivityFromNetGuard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intentForMainActivityFromNetGuard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intentForMainActivityFromNetGuard.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
Random generator = new Random();
pendingIntent = PendingIntent.getActivity(ActivityMain.getInstance(), generator.nextInt(), intentForMainActivityFromNetGuard, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
try {
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
Log.i(TAG, " - updateAcces - Attempt to trigger execution of MainActivityFromNetGuard FAILED --- ");
e.printStackTrace();
}
Upvotes: 0
Views: 715