We want user can open new class when touch to
notification on status bar.
Create function like this.
private void noti(Context context, int notificationNumber, String ten, String noidung) {
NotificationManager
notificationManager =
(NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context,
newclass.class);
PendingIntent intent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
Notification notification=new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(ten).setContentText(noidung)
.setContentIntent(intent).build();
notificationManager.notify(notificationNumber , notification);
}
Call function like this.
noti(this, 1338,
"title", "content");
No comments:
Post a Comment