0

Buen día tengo el siguiente conflicto, tengo dos archivos mi GeofenceIntentService.java y mi BaseActivityHelper.java

Deseo llamar desde mi GeofenceInt... un metodo que tengo en mi BaseActiv...

GeofenceIntentService.java:


@Override
    protected void onHandleIntent(Intent intent) {

        if (intent.getBooleanExtra(FORZAR_NOTIFICACION, false)) {
            procesarTriggeringGeofences(null);
            mostrarNotificacionDirec();
            dialogDirec();

            return;
        }

        GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
        if (geofencingEvent.hasError()) {
            Log.e(TAG_LOG, GeofenceStatusCodes.getStatusCodeString(geofencingEvent.getErrorCode()));
            return;
        }

        // Get the transition type.
        int geofenceTransition = geofencingEvent.getGeofenceTransition();

        // Test that the reported transition was of interest.
        if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) {
            List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();

            procesarTriggeringGeofences(triggeringGeofences);
            mostrarNotificacionDirec();
            dialogDirec();
        } else {
            Log.e(TAG_LOG, String.format("Código no soportado de transicion de Geofence %s",
                    geofenceTransition));
        }
    }
private void dialogDirec() {
        BaseActivityHelper BAH = new BaseActivityHelper();
        BAH.salirPdvDialog();
    }

y:

BaseActivityHelper.java:

@ContextSingleton
public class BaseActivityHelper {
    public void salirPdvDialog() {

        AlertDialog.Builder builderr = new AlertDialog.Builder(mActivity, R.style.StyledDialog);
        builderr.setTitle(R.string.confirmacion_salida_pdv_dir)
                .setMessage(R.string.saliendo_de_punto_dirr)
                .setCancelable(false);
        AlertDialog dialog = builderr.create();
        dialog.show();
    }
}

Tengo el siguiente Error:

FATAL EXCEPTION: IntentService[GeofenceIntentService]
    Process: com.android.app, PID: 25724
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
3
  • En el código no se muestra donde llamas getSystemService(), agrega esa parte por favor, saludos.
    – Jorgesys
    el 20 sep. 2019 a las 14:31
  • NO comprendo a que te refieres, es metodo de Context, no? el 20 sep. 2019 a las 14:37
  • Lo sé, pero en el código que agregas en tu pregunta no se ve donde realizas esa parte, desde donde lo llamas?
    – Jorgesys
    el 20 sep. 2019 a las 15:29

1 respuesta 1

0

@Jorgesys Pedona no me deja responder ni editar la pregunta

La llamo en un inicio asi:

import android.content.Context;
@Inject
 private Context mContext;

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.