Skip to content

Instantly share code, notes, and snippets.

@louisbl
Created October 15, 2014 12:58
Show Gist options
  • Save louisbl/846a4b3b10b76b1e6e90 to your computer and use it in GitHub Desktop.
Save louisbl/846a4b3b10b76b1e6e90 to your computer and use it in GitHub Desktop.
Android notification
// Notifications
Intent resultIntent = new Intent(this, PlayListActivity.class);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(this,
0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT
);
NotificationCompat.Builder notifBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(android.R.drawable.ic_dialog_alert)
.setContentIntent(resultPendingIntent)
.setAutoCancel(true)
.setContentTitle("A notification!")
.setContentText("Notifcation content");
int mNotificationId = 12;
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.notify(mNotificationId, notifBuilder.build());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment