【问题标题】:Android - Changing notification's ContentText on a button clickAndroid - 单击按钮更改通知的 ContentText
【发布时间】:2017-01-17 19:00:08
【问题描述】:

我有一个包含一个按钮的通知,在该通知.setContentText() 中,有一个谚语从包含许多谚语的字符串数组中显示出来,我想要做的是当我单击该通知按钮时,一个新的谚语是分配给.setContestText()

我尝试在 SO 上寻找其他解决方案,但没有得到类似的解决方案

当前结果:当我点击按钮时没有任何反应

这是我目前的代码:

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);
}

【问题讨论】:

    标签: java android push-notification notifications


    【解决方案1】:

    您不能这样做,一旦发送通知,您就无法更改其内容 看看ANDROID NOTIFICATIONS

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多