Guest User

Untitled

a guest
Oct 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. FATAL EXCEPTION: main
  2. Process: :my_service, PID: 28490
  3. java.lang.RuntimeException: Unable to instantiate service .serviciosUbicacion.servicioUbicacion: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
  4. at android.app.ActivityThread.handleCreateService(ActivityThread.java:2962)
  5. at android.app.ActivityThread.access$1800(ActivityThread.java:178)
  6. at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1553)
  7. at android.os.Handler.dispatchMessage(Handler.java:111)
  8. at android.os.Looper.loop(Looper.java:194)
  9. at android.app.ActivityThread.main(ActivityThread.java:5631)
  10. at java.lang.reflect.Method.invoke(Native Method)
  11. at java.lang.reflect.Method.invoke(Method.java:372)
  12. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
  13. at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
  14. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
  15. at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:106)
  16. at serviciosUbicacion.servicioUbicacion$LocationListener.<init>(servicioUbicacion.java:50)
  17.  
  18. public class Preferencias {
  19.  
  20.  
  21.  
  22. public static final String idUsuario="00";
  23.  
  24. public final SharedPreferences misPreferencias;
  25. public boolean estaLogueado = false;
  26.  
  27. private static Preferencias INSTANCIA;
  28.  
  29.  
  30. public static Preferencias get(Context context) {
  31. if (INSTANCIA == null) {
  32. INSTANCIA = new Preferencias(context);
  33. }
  34. return INSTANCIA;
  35. }
  36. public Preferencias(Context context) {
  37. misPreferencias = context.getApplicationContext().getSharedPreferences(empleado, Context.MODE_PRIVATE);
  38. estaLogueado = !TextUtils.isEmpty(misPreferencias.getString(NIT, null));
  39. }
  40.  
  41. private class LocationListener implements android.location.LocationListener{
  42. Location mLastLocation;
  43. String ubicacion="";
  44. Preferencias preff = new Preferencias(getApplicationContext());
  45. int id_usuario = preff.misPreferencias.getInt(idUsuario,0);
  46. ...............................................................................................
Add Comment
Please, Sign In to add comment