2012-02-22 6 views
15

Im usando unos sensores - MediaRecorder y MediaPlayer, NotificationManager, un WakeLock y LocationListener ...android.app.SuperNotCalledException: Actividad no llamó a través de super.onStop()

Aquí está mi onResume() y onPause() funciones:

void onResume() { 
    super.onResume(); 

    //GPS Sensor 
    locationListener = new MyLocationListener(); 
    locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
    locationManager.requestLocationUpdates(
     LocationManager.GPS_PROVIDER, 0, 0, locationListener); 

    // Notification Manager 
    gNotificationManager = 
     (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
    gNotification = new Notification(); 
    gNotification.vibrate = gVibrate; 

} 

...

void onPause() { 
    super.onPause(); 

    // Release the Recorder 
    if (mRecorder != null) { 
    mRecorder.release(); 
    mRecorder = null; 
    } 

    // Release the Media Player 
    if(mPlayer != null) { 
    mPlayer.release(); 
    mPlayer = null; 
    } 

    // Release Power Manager 
    wake.Stop(); 
    wake = null; 

    // Release Location Listener 
    locationManager.removeUpdates(locationListener); 
    locationManager = null; 

} 

y aquí está la salida Logcat ...

threadid=1: thread exiting with uncaught exception 
(group=0x40015560) 
FATAL EXCEPTION: main 
android.app.SuperNotCalledException: Activity 
{changethispackage.beforesubmitting.tothemarket.sonicdrift/ 
changethispackage.beforesubmitting.tothemarket.sonicdrift.SonicDrift} 
did not call through to super.onStop() 

at android.app.Activity.performStop(Activity.java:3875) 
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2619) 
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2690) 
at android.app.ActivityThread.access$2100(ActivityThread.java:117) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:964) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:130) 
at android.app.ActivityThread.main(ActivityThread.java:3683) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:507) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
at dalvik.system.NativeStart.main(Native 
Method) W/InputManagerService( 96): Window already focused, ignoring 
focus gain of: 
[email protected] 
I/Process (17118): Sending signal. PID: 17118 SIG: 9 
I/ActivityManager( 96): Process 
changethispackage.beforesubmitting.tothemarket.sonicdrift (pid 17118) 
has died. I/WindowManager( 96): WIN DEATH: Window{40958d98 
changethispackage.beforesubmitting.tothemarket.sonicdrift/changethispackage. 
beforesubmitting.tothemarket.sonicdrift.SonicDrift 
paused=false} I/WindowManager( 96): WIN DEATH: Window{40991f90 
SurfaceView paused=false} 

¿Cómo puedo corregir este error? Intenté agregar super.onStop() a mi onPause().

+0

Compruebe esto puede ayudarlo http://stackoverflow.com/questions/3124965/android-unable-to-stop-activity – kosa

+0

Sí, ese fue uno de los que encontré antes de publicar ... Supongo que b/c No tengo una función onStop(), no estaba seguro de que la necesitaba ... también intenté agregar super.onStop() a mi función onPause(), pero el mismo error ... –

+0

No, debes tener función de parada. No puede llamar a super.onStop() desde pausa. Pausa/Parada son operaciones diferentes. – kosa

Respuesta

39

Debe asegurarse de tener super.onStop y super.onDestroy en sus métodos reemplazados. Esto podría ser un buen candidato para el problema que tiene:

@Override 
protected void onStop() { 
    Log.w(TAG, "App stopped"); 

    super.onStop(); 
} 

@Override 
protected void onDestroy() { 
    Log.w(TAG, "App destroyed"); 

    super.onDestroy(); 
} 
+0

Perdón por tardar tanto en aceptar esta respuesta ... la forma en que Processing solía funcionar, en realidad no admitía estos métodos de manera inmediata (es una divertida biblioteca de alto nivel para Android), así que estaba confundido acerca de su implementación ... todo arreglado ahora sin embargo. –

0

dejó de lanzar Excepciones después de añadir eventos vacíos onPause y onResume (He añadido sus métodos de todos modos, sólo para estar seguro).

Altough, la segunda actividad todavía se detiene aparentemente sin motivo. Pero haré otra pregunta sobre eso.

Cuestiones relacionadas