Ho una notifica nella mia app con il seguente codice:
//Notification Start
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.n1;
CharSequence tickerText = "Call Blocker";
long when = System.currentTimeMillis(); //now
Notification notification = new Notification(icon, tickerText, when);
Intent notificationIntent = new Intent(context, Main.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
Context context = getApplicationContext();
CharSequence title = "Call Blocker";
text = "Calls will be blocked while driving";
notification.setLatestEventInfo(context, title, text, contentIntent);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notificationManager.notify(1, notification);
}
Le mie notifiche si attivano molto bene, ma il mio problema è che, quando clicco sulla notifica nel Centro notifiche, la mia app non si avvia.
In sostanza, dopo aver cliccato sulla mia notifica non succede nulla! Cosa devo fare per iniziare la mia attività principale dopo aver cliccato sulla mia notifica. Grazie.
Context context = getApplicationContext();
prima Notification notification = new Notification(icon, tickerText, when);
forse non stai passando il contesto giusto per iniziare l'attività