海想設置報警每10 minutes.But其運行僅第一次任何機構好心幫我如何在Android應用程序中每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
用代碼中的alarmManager替換(1 * 1000)(10 * 60 * 1000)。 – Hiral