Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FATAL EXCEPTION: main
- Process: :my_service, PID: 28490
- 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
- at android.app.ActivityThread.handleCreateService(ActivityThread.java:2962)
- at android.app.ActivityThread.access$1800(ActivityThread.java:178)
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1553)
- at android.os.Handler.dispatchMessage(Handler.java:111)
- at android.os.Looper.loop(Looper.java:194)
- at android.app.ActivityThread.main(ActivityThread.java:5631)
- at java.lang.reflect.Method.invoke(Native Method)
- at java.lang.reflect.Method.invoke(Method.java:372)
- at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
- Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
- at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:106)
- at serviciosUbicacion.servicioUbicacion$LocationListener.<init>(servicioUbicacion.java:50)
- public class Preferencias {
- public static final String idUsuario="00";
- public final SharedPreferences misPreferencias;
- public boolean estaLogueado = false;
- private static Preferencias INSTANCIA;
- public static Preferencias get(Context context) {
- if (INSTANCIA == null) {
- INSTANCIA = new Preferencias(context);
- }
- return INSTANCIA;
- }
- public Preferencias(Context context) {
- misPreferencias = context.getApplicationContext().getSharedPreferences(empleado, Context.MODE_PRIVATE);
- estaLogueado = !TextUtils.isEmpty(misPreferencias.getString(NIT, null));
- }
- private class LocationListener implements android.location.LocationListener{
- Location mLastLocation;
- String ubicacion="";
- Preferencias preff = new Preferencias(getApplicationContext());
- int id_usuario = preff.misPreferencias.getInt(idUsuario,0);
- ...............................................................................................
Add Comment
Please, Sign In to add comment