タイトルの通り、android localnotification phonegap プラグインを使用しています。これで、そのバーに通知を強制することができます。そのバーに触れると、アプリが再び開きますが、その通知はまだ通知バーにあります。
ここでの質問は、アプリが再度開かれたときに通知バーでその通知をクリアする方法ですか?
ありがとう。
タイトルの通り、android localnotification phonegap プラグインを使用しています。これで、そのバーに通知を強制することができます。そのバーに触れると、アプリが再び開きますが、その通知はまだ通知バーにあります。
ここでの質問は、アプリが再度開かれたときに通知バーでその通知をクリアする方法ですか?
ありがとう。
AlarmReceiver.java
を見てAlarmReceiver::onReceive(Context context, Intent intent)
ください。に設定する必要がAutoCancel
ありNotification
ます。
使用している API のバージョンによって、これは異なる場合があります。バージョン 17 の場合、次のようになります。
final Notification notification = new NotificationCompat.Builder(context)
.setTicker(tickerText)
.setSmallIcon( context.getResources().getIdentifier("myicon" ,
"drawable", context.getPackageName()) )
.setWhen(System.currentTimeMillis())
.setContentTitle(notificationTitle)
.setContentText(notificationSubText)
.setContentIntent(contentIntent)
// .setVibrate(new long[] { 0, 100, 200, 300 })
.setAutoCancel(true) // <------- here you remove the message
.build();
notificationMgr.notify(notificationId, notification);