public class SchedulerSetupReceiver extends WakefulBroadcastReceiver {
private static final String APP_TAG = "com.hascode.android";
private static final int EXEC_INTERVAL = 10 * 1000;
DBhelper dbhelper;
@Override
public void onReceive(final Context ctx, final Intent intent) {
Log.d(APP_TAG, "SchedulerSetupReceiver.onReceive() called");
dbhelper = new DBhelper(ctx);
String [] ID=dbhelper.FetchAllID();
String[] time=dbhelper.FetchAlltime();
for(int k=0;k<ID.length;k++)
{
AlarmManager alarmManager = (AlarmManager) ctx
.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(ctx, SchedulerEventReceiver.class); // explicit
// intent
PendingIntent intentExecuted = PendingIntent.getBroadcast(ctx, 0, i,
PendingIntent.FLAG_CANCEL_CURRENT);
Calendar now = Calendar.getInstance();
now.add(Calendar.SECOND, 20);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
now.getTimeInMillis(), EXEC_INTERVAL, intentExecuted);
}
}
}
で与えられた時間にアラームを設定する方法これは、各20秒でアラームを繰り返すための私のコードですが、私はアラームが3.30で、4.50は、8.30のいずれかが、私は繰り返しの設定に変更されるものを私に提案することができます設定する必要がありますしたいですメソッドを呼び出すと、Alarmがブロードキャストされ、ブロードキャストでいくつかの条件をテストできるように、それぞれ3.30、4.50,8.30にキャストされます。アンドロイド
私はこれを使用している24時間 – Pooya
http://paste.ofcode.org/iDRAvSGaGBCBYZMv6aT9JQのために3つの別々の繰り返しのアラームをそれぞれ設定するが、私はにに問題に直面しています:私は、これはあなたが
NotificationReceiverが助けになると思います私のローカルデータベースから来ている時間を設定してください[ –
あなたの時間はどのパターンにも従っていません。 forループではなく別のアラームを使用する必要があります – Pooya