gpt4 book ai didi

android.app.SuperNotCalledException : Activity did not call through to super. onStop()

转载 作者:IT老高 更新时间:2023-10-28 23:28:49 46 4
gpt4 key购买 nike

我正在使用一些传感器 - MediaRecorder 和 MediaPlayer、NotificationManager、WakeLock 和 LocationListener...

这是我的 onResume() 和 onPause() 函数:

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;

}

这是 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:
com.android.internal.view.IInputMethodClient$Stub$Proxy@40713650
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}

如何解决此错误?我尝试将 super.onStop() 添加到我的 onPause() 中。

最佳答案

您需要确保您的重写方法中有 super.onStopsuper.onDestroy。对于您遇到的问题,这可能是一个很好的候选:

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

super.onStop();
}

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

super.onDestroy();
}

关于android.app.SuperNotCalledException : Activity did not call through to super. onStop(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9397020/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com