【发布时间】:2013-12-28 15:24:36
【问题描述】:
我有一个必须在重启后才能工作的代码;这是一项服务,它将重新创建我在设备关闭之前曾经拥有的警报......
我的代码是:
public void onReceive(Context context, Intent intent) {
c=context;
sp= PreferenceManager.getDefaultSharedPreferences(context);
sp.edit().putInt("CheckeForConnectionNumber", 0).commit();
Toast.makeText(c,"checknumber= "+sp.getInt("CheckeForConnectionNumber",
0), Toast.LENGTH_LONG).show();
bool_activate_reminder=sp.getBoolean("reminder_on_off", false);
if(bool_activate_reminder==true){
//if I start it on the reboot it will take wrong info and return wrong hours..
Intent inte = new Intent(c,AlarmService.class);
c.startService(inte);
}
所以它正在调用一个服务,该服务将在设备重新启动后重新创建警报 并创建我需要获取位置的警报;它运行良好,但有时该位置被视为 0.0,因为设备没有足够的时间来检索它; 我创建了一个线程,该线程会在一段时间后启动服务,但它没有按需要工作......那我该怎么办?
【问题讨论】:
标签: android service location reboot