2

通知を送信するたびに、デバイスは通知が無限に送信されたかのように動作します。つまり、通知メニューを開くまで、着信音とバイブレーションが鳴り続けます。notification.flag |= 行をコメントアウトすると、この動作を停止できますが、自動キャンセルフラグを使用できません。これを引き起こしている原因についてのアイデアはありますか?

         NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
                 .setSmallIcon(resourceID)
                 .setContentTitle(title)
                 .setContentText(contentText)
                 .setSound(soundUri, RingtoneManager.TYPE_NOTIFICATION)
                 .setVibrate(CommonUtilities.VIBRATE_PATTERN); 

         Notification notification = mBuilder.build();


         /* comment this out to stop the infinite notification loop */

         notification.flags |= Notification.DEFAULT_LIGHTS 
                 | Notification.FLAG_AUTO_CANCEL
                 | Notification.FLAG_ONLY_ALERT_ONCE;


         Intent intent = new Intent(this, DashboardActivity.class);
         PendingIntent activity = PendingIntent.getActivity(this, CommonUtilities.REQUEST_NOTIFICATION, intent, 0);
         String pref = getSharedPreferences(CommonUtilities.NOTIFICATION_PEF, MODE_PRIVATE).getString("incoming", contentText);
         notification.setLatestEventInfo(this, title ,pref, activity);

        notification.number += 1;
         //Display notification
        notificationManager.notify(0, notification);
4

1 に答える 1