0

5 分ごとに (サービスから) 通知を更新または更新するようにしています。これどうやってするの?これは、私が更新したいものです。

if (...){

            int icon = R.drawable.updatedImage1;
            long when = System.currentTimeMillis();
            NotificationManager notificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);
            CharSequence message = "II Tydzień";        
            Notification notification = new Notification(icon, message, when );
            String title = this.getString(R.string.app_name); // Here you can pass the value of your TextView
            Intent notificationIntent = new Intent(this, MainActivity.class);
            notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
            PendingIntent intent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
            notification.setLatestEventInfo(this, title, message, intent);
            notification.flags |= Notification.FLAG_NO_CLEAR;
            notificationManager.notify(0, notification);  

} else { ...other notification }

条件は期間なので、何時かによって通知を変える必要があります。

4

1 に答える 1

0

AlarmManagerを使用して、異なる時間間隔で繰り返し通知をスケジュールできます。ドキュメントには次のように記載されています。

このクラスは、システム アラーム サービスへのアクセスを提供します。これらにより、将来のある時点でアプリケーションを実行するようにスケジュールできます。アラームが鳴ると、登録されていたインテントがシステムによってブロードキャストされ、ターゲット アプリケーションがまだ実行されていない場合は自動的に開始されます。

目的に合わせてsetRepeating関数を使用できる場合があります。

于 2013-11-11T18:30:38.133 に答える