2
How do I start the requestLocationUpdates() with Thread.sleep(); in the Android?
My code:
public void onLocationChanged(Location loc) {
    Date d = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    SQLiteDatabase db = openOrCreateDatabase("pontos.db", Context.MODE_PRIVATE, null);       
    db.execSQL("INSERT INTO pontos(latitude, longitude, datahora) VALUES('"+ loc.getLatitude()+"','"+loc.getLongitude()+"','"+  sdf.format(d)+"')");
   db.close();
 Toast.makeText(getBaseContext(), "Atualizado", Toast.LENGTH_LONG).show();      
 locationManager.removeUpdates(this);   
  incremento();
}
private void incremento() {
     new Thread(new Runnable() {
           @Override
          public void run() {
               try {
                  Thread.sleep(5000);
                                      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new Servico());
               }catch(Exception e){}
                 }
            }).start(); 
}
I call the incremento(); at the end of onLocationChanged(), but nothing happens.
Detail: this is a service in Background.
It would be very interesting if you put some printStackTrace or even if it was a System.out.println inside the catch, because you are "swallowing" the exception. If there’s something wrong you won’t see what it was.
– prmottajr