如何设置报警每10分钟Android应用程序? [英] How to set alarm for every 10 minutes in Android Application?
问题描述
海正尝试设置报警每10 minutes.But它的运行仅第一次任何机构好心帮我
意向意图=新的意图(这一点,ConnectionReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(此,0,
意图,PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager =(AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,System.currentTimeMillis的()+(1 * 1000),pendingIntent);
Toast.makeText(这一点,报警设置,Toast.LENGTH_LONG).show(); //每10分钟我要打印的敬酒
使用alarmManager.setRepeating方法
遵循开发者的网站链接
<一个href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlarmService.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlarmService.html
<一个href="http://developer.android.com/reference/android/app/AlarmManager.html#setRepeating%28int,%20long,%20long,%20android.app.PendingIntent%29" rel="nofollow">http://developer.android.com/reference/android/app/AlarmManager.html#setRepeating(int,很长很长,android.app.PendingIntent)
Hai am trying to set alarm for every 10 minutes.But its running first time only any Body kindly help me
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
use alarmManager.setRepeating method
follow this link on developer site
这篇关于如何设置报警每10分钟Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!