Android 如何使onreboot服务以更好的方式工作
我有一个代码,必须重新启动工作;这是一项服务,它将重新创建设备关闭前我曾经拥有的警报 我的代码是:Android 如何使onreboot服务以更好的方式工作,android,service,location,reboot,Android,Service,Location,Reboot,我有一个代码,必须重新启动工作;这是一项服务,它将重新创建设备关闭前我曾经拥有的警报 我的代码是: public void onReceive(Context context, Intent intent) { c=context; sp= PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putInt("CheckeForConnectionNu
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;
我创建了一个线程,在一段时间后启动该服务,但它不能按需要工作。。。那我该怎么办呢?我做了什么:
OnBootReceiver我创建了一个闹钟,一分钟后就会响,关闭后会调用服务;
这样的话,位置是以正确的方式确定的,并且没有
latitude=0.0
longitude=0.0
问题还没有解决