如何设置报警每10分钟Android应用程序?应用程序、如何设置、Android

2023-09-04 05:23:44 作者:皒鈊為亇流血

海正尝试设置报警每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方法

遵循开发者的网站链接

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlarmService.html

http://developer.android.com/reference/android/app/AlarmManager.html#setRepeating(int,很长很长,android.app.PendingIntent)

三分钟学会提交Android应用程序在谷歌Play商店

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

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlarmService.html

http://developer.android.com/reference/android/app/AlarmManager.html#setRepeating(int, long, long, android.app.PendingIntent)