1
votes

I have a notification that contains a button, inside that notification .setContentText() there is a proverb shown from an array of strings containing numerous proverbs, what I'm trying to do is when I click that notification button a new proverb is assigned to .setContestText()

I tried looking for other solutions on SO but I got nothing similar

Current result : When I click the button nothing happens

Here is my code so far:

public void notif(){
    int icon = getRandomIc();
    String Prov = getRandomProverb();
    String newProverb = getRandomProverb();
    Intent reloadQ = new Intent(this, Splash.class);

    PendingIntent piReload = PendingIntent.getService(this, 0, reloadQ, 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
    Notification notification = mBuilder
            .setSmallIcon(icon)
            .setVibrate(new long[] { 1000, 1000 })
            .setLights(Color.BLUE, 700, 500)
            .setContentTitle("Notification title")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(NorProv))
            .addAction(R.mipmap.ic_autorenew_black_24dp, "New quote", piReload)
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))            
            .setContentText(Prov)
            .build();

    NotificationManager nMN = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nMN.notify(NOTIFICATION_ID, notification);
}
1

1 Answers

1
votes

You can't do that, once a notification is sent you cannot change it's content take a look at ANDROID NOTIFICATIONS