int mNotificationId = 001;
private void generateNotification(Context mContext, String message) {
Intent notificationIntent = new Intent(mContext, MainActivity.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(mContext, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
Notification notification = mBuilder.setSmallIcon(R.drawable.alert).setTicker(getResources().getString(R.string.app_name)).setWhen(0)
.setAutoCancel(true)
.setContentTitle(getResources().getString(R.string.app_name))
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setContentIntent(resultPendingIntent)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_logo))
.setContentText(message).build();
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId, notification);
}
Hello everyone, The purpose of this blog is to give you all kind of technical support in simple manner. Find latest technology support every time so as to keep you updated on daily basis. Exact source code snippet will help you understand more and integrate same in difficult situation. Note: Blog is maintained by Nikhil Lotke.
Tuesday, January 31, 2017
Multiline push notification in Android
Labels:
android
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment