Как установить будильник на каждые 10 минут в приложении для Android? - PullRequest
0 голосов
/ 24 января 2012

Хай пытаюсь установить будильник каждые 10 минут. Но он запускается впервые только любым телом, пожалуйста, помогите мне

Intent intent = new Intent(this, ConnectionReceiver.class);

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
intent, PendingIntent.FLAG_ONE_SHOT);

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1 * 1000),   pendingIntent);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();//every 10 minutes i want to print the toast

Ответы [ 2 ]

2 голосов
/ 03 сентября 2012
    Calendar calCurrent = Calendar.getInstance();
    long tenmin = 10 * 60 * 1000;
    int mynotifyidis = Integer.parseInt(mydelid);
    Intent mIntent = new Intent(this, NotificationService1.class);
    mIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    mIntent.putExtra("id", mynotifyidis);

    AlarmManager mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    PendingIntent snoozependingintent = PendingIntent.getService(this,
            -mynotifyidis, mIntent, PendingIntent.FLAG_ONE_SHOT);

    mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
            calCurrent.getTimeInMillis() + fivemin, fivemin,
            snoozependingintent);
1 голос
/ 24 января 2012
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...