Answer the question
In order to leave comments, you need to log in
How to handle a click on a notification?
Hello everyone, there is a notification. I want to send information to the metric when clicked. I know how to open another activity by clicking on a notification, but I don’t know how easy it is to use the method as in a regular button.
PS method from the metric itself reportEvent("blah blah"). Thanks in advance
private void sentNotification(){
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Закажите фотокнигу")
.setContentText("И получите магнитик с Вашим фото")
.setSound(uri)
.setTicker("Подарок от ");
Notification notification = builder.build();
NotificationManager notificationManager =
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question