title: Location tracking Exception thread id=1: thread exiting with uncaught exception (group=0x4170ed58)
body: <p>I am new to android and I am developing an app that takes location for every minute and send it to server.This code works fine in my tab but it get closed when i install this in my redmi phone. Both have same version. My app get closed when it execute the location change method. I have mentioned my code for location change and error log below.</p>
  
  <pre><code> public void onLocationChanged(Location location) {
  
      sharedpreferences=getApplicationContext().getSharedPreferences
              (MyPREFERENCES,getApplicationContext().MODE_PRIVATE);
      uid=sharedpreferences.getString("uid",null);
      u_name=sharedpreferences.getString("u_name",null);
      Log.e(TAG, "Firing onLocationChanged..............................................");
      //Toast.makeText(getApplicationContext(),"uid" + uid,Toast.LENGTH_LONG).show();
      mCurrentLocation = location;
      mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());
      lati = mCurrentLocation.getLatitude();
      longi = mCurrentLocation.getLongitude();
      String lat = Double.toString(lati);
      String lon = Double.toString(longi);
      //Toast.makeText(this,"user_id" + uid, Toast.LENGTH_LONG).show();
      //Toast.makeText(this,"user_name" + u_name, Toast.LENGTH_LONG).show();
      Toast.makeText(this, "latitude = " + lati, Toast.LENGTH_LONG).show();
      Toast.makeText(this, "longitude = " + longi, Toast.LENGTH_LONG).show();
  
      try{
          new Save_asyncTask().execute(lat,lon,uid);
      }catch(Exception e){
          e.printStackTrace();
          Log.e(TAG, "Error thrown when calling Asyn Task", e);
          Toast.makeText(getApplicationContext(),"Async error", Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>This is my error log</p>
  
  <pre><code>08-12 15:50:52.147    3248-3248/com.example.netaxis_41.dial4meat W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4170ed58)08-12 15:50:52.157    3248-3248/com.example.netaxis_41.dial4meat E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.example.netaxis_41.dial4meat, PID: 3248
  java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
          at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
          at java.util.ArrayList.get(ArrayList.java:308)
          at com.example.netaxis_41.dial4meat.LocationNdSend.onLocationChanged(LocationNdSend.java:162)
          at com.google.android.gms.location.internal.zzi$zzb.handleMessage(Unknown Source)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:136)
          at android.app.ActivityThread.main(ActivityThread.java:5111)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>