this code is working for above version of 2.3 (not working for 2.3)
Intent resultIntent = new Intent(this, MainActivity.class);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.abc_logo)
.setContentTitle("My Title")
.setWhen(System.currentTimeMillis())
.setContentIntent(pendingIntent)
.setContentText("My text");
mBuilder.setContentIntent(pendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(NOTIFY_ID, mBuilder.build());
With PendingIntent.getBroadcast()
you're intending to send broadcast to all possible receivers.
The problem is in:
resultIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
It will NOT be used to start an Activity. So you cannot set any of the Activity-related flags like FLAG_ACTIVITY_SINGLE_TOP.
Remove it and it should work on GB too.
You can only set Activity-related Intent flags in a PendingIntent, as long as you call getActivity() to get the PendingIntent.