下面我将要使用的报警服务,在每30分钟打报警。现在我已经将它设置为从每一个每10秒启动,以发挥它。
Here i am going to use the alarm service to play the alarm at every 30 minutes. Right now i have set it to play it at every 10 second from the Every start.
下面是code:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_layout);
Intent myIntent = new Intent(SettingsActivity.this, MyAlarmService.class);
pendingIntent = PendingIntent.getService(SettingsActivity.this, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 10*1000, pendingIntent);
}
现在的问题是,我要开始从12:30不是从应用程序时开始报警,并应在反复外翻30分钟发挥。像1:00,1:30,2:00。 。 。等
Now the Problem is, I want to start the alarm from the 12:30 not from the time application start and it should repeatedly play at evert 30 minutes. like 1:00, 1:30, 2:00 . . . etc
所以,我有什么样的变化做我的code?
So what changes i have to do in my code ?
要开始在特定时间的服务。 看到这个帖子也许有帮助的:
To start a service at specific time. see this post maybe helpful:
Using Alarmmanager在特定时间启动服务