現在の通知を削除するためにこのサンプル コードを使用すると正常に動作しますが、このコードでこのタイマーが何をしているのか知りたいですか? 私は19秒ごとに通知を削除したいので、コードには2つのタイマーがあり、30分ごとに通知を削除したい場合はどちらを変更しますか?? このtewoタイマーの機能は何ですか? myTimer.schedule(myTask, 19 * 1000 , 19 * 1000);
30分ごとに削除通知を行うと、どれを変更しますか???
public class TimeAlarm extends BroadcastReceiver {
NotificationManager nm;
@Override
public void onReceive(Context context, Intent intent) {
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = "CherryApplication";
CharSequence message = "Launcher application for games.";
MyTimerTask myTask = new MyTimerTask();
Timer myTimer = new Timer();
Intent startMyActivity = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
startMyActivity, 0);
Notification notif = new Notification(R.drawable.cherry_icon,
"CherryApplication", System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
nm.notify(1, notif);
myTimer.schedule(myTask, 19 * 1000, 19 * 1000);
}
class MyTimerTask extends TimerTask {
public void run() {
nm.cancel(1);
System.out.println("");
}
}
}