Skip to content

Instantly share code, notes, and snippets.

@cavarzan
Last active December 27, 2015 01:53
Show Gist options
  • Save cavarzan/947df18d57d0ccf9e651 to your computer and use it in GitHub Desktop.
Save cavarzan/947df18d57d0ccf9e651 to your computer and use it in GitHub Desktop.
public class PushIntentService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
handleNotification(intent.getExtras());
}
private void handleNotification(Bundle extras) {
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = extras.getParcelable(Extras.NOTIFICATION);
if (notification == null) {
return;
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(notification.title)
.setContentText(notification.message)
.setAutoCancel(true);
mNotificationManager.notify("default-push", 1, mBuilder.build());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment