What I did:
OnBootReceiver I created an alarm that goes off after a minute and that calls the service when turned off; That way the location is taken in a correct way and don't have the
latitude=0.0
longitude=0.0
problem anymore...
Question
I have a code that must work on reboot; It's a service that will recreate the alarms that I used to have before that the device shut down...
My code is :
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);
}
so it's calling a service that will recreate the alarms after that the device has rebooted and to create the alarms I need to get the location; It's working perfectly but sometimes the location is taken as 0.0 because the device doesn't have enough time to retrieve it; I created a thread that launches the service after a certain time but that's not working as needed... so what should I do?
Solution
What I did:
OnBootReceiver I created an alarm that goes off after a minute and that calls the service when turned off; That way the location is taken in a correct way and don't have the
latitude=0.0
longitude=0.0
problem anymore...