I have an app in which i have to update notification text and title without sending new notification. How do i do that i have tried below mentioned code.
code:-
notifica("Test", "Testinggggggggggg");
m_send = (Button) findViewById(R.id.send_another);
m_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
builder.setContentTitle("Test3");
builder.setContentText("Test3333333333");
notificationManager.notify(0, builder.build());
}
});
}
public void notifica(String title, String message) {
int color = getResources().getColor(R.color.colorPrimary);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Intent intent = new Intent(this, HomeScreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
builder = new NotificationCompat.Builder(this);
builder.setContentTitle(title);
builder.setContentText(message);
builder.setAutoCancel(false);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setColor(color);
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
builder.setSound(defaultSoundUri);
builder.setContentIntent(pendingIntent);
notificationManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
}
}