Created
December 3, 2012 03:50
-
-
Save qhm123/4192565 to your computer and use it in GitHub Desktop.
How exactly to use Notification.Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent notificationIntent = newIntent(ctx, YourClass.class); | |
PendingIntent contentIntent = PendingIntent.getActivity(ctx, | |
YOUR_PI_REQ_CODE, notificationIntent, | |
PendingIntent.FLAG_CANCEL_CURRENT); | |
NotificationManager nm = (NotificationManager) ctx | |
.getSystemService(Context.NOTIFICATION_SERVICE); | |
Resources res = ctx.getResources(); | |
Notification.Builder builder = newNotification.Builder(ctx); | |
builder.setContentIntent(contentIntent) | |
.setSmallIcon(R.drawable.some_img) | |
.setLargeIcon( | |
BitmapFactory.decodeResource(res, | |
R.drawable.some_big_img)) | |
.setTicker(res.getString(R.string.your_ticker)) | |
.setWhen(System.currentTimeMillis()).setAutoCancel(true) | |
.setContentTitle(res.getString(R.string.your_notif_title)) | |
.setContentText(res.getString(R.string.your_notif_text)); | |
Notification n = builder.build(); | |
nm.notify(YOUR_NOTIF_ID, n); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment