error the application stopped when press mobile logout button

坚强是说给别人听的谎言 提交于 2019-12-14 03:03:57

问题


I have Android app which play sound and when I want to log off from the app as when press on mobile logout button i have the error message " the application stopped ..." .

@Override
protected void onStop() {

         super.onStop(); 

    if(mp.isPlaying())
      mp.stop();
      mp.release();
      finish();
      }


@Override
public void onBackPressed() {
    // TODO Auto-generated method stub
    super.onBackPressed();


    if(mp!=null)
    {


         if(mp.isPlaying())

      mp.stop();
         mp.release();


    }
    finish();

}

06-30 00:09:48.403: I/Choreographer(678): Skipped 106 frames! The application may be doing too much work on its main thread. 06-30 00:09:48.452: D/gralloc_goldfish(678): Emulator without GPU emulation detected. 06-30 00:09:49.761: I/Choreographer(678): Skipped 135 frames! The application may be doing too much work on its main thread. 06-30 00:09:51.331: D/dalvikvm(678): GC_CONCURRENT freed 82K, 2% free 8378K/8519K, paused 123ms+21ms, total 278ms 06-30 00:10:18.202: W/IInputConnectionWrapper(678): showStatusIcon on inactive InputConnection 06-30 00:10:19.042: D/AndroidRuntime(678): Shutting down VM 06-30 00:10:19.042: W/dalvikvm(678): threadid=1: thread exiting with uncaught exception (group=0x40a13300) 06-30 00:10:19.211: E/AndroidRuntime(678): FATAL EXCEPTION: main 06-30 00:10:19.211: E/AndroidRuntime(678): android.app.SuperNotCalledException: Activity {com.ramadan/com.ramadan.Ramadan} did not call through to super.onStop() 06-30 00:10:19.211: E/AndroidRuntime(678): at android.app.Activity.performStop(Activity.java:5148) 06-30 00:10:19.211: E/AndroidRuntime(678): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3232) 06-30 00:10:19.211: E/AndroidRuntime(678): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3291) 06-30 00:10:19.211: E/AndroidRuntime(678): at android.app.ActivityThread.access$1200(ActivityThread.java:130) 06-30 00:10:19.211: E/AndroidRuntime(678): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248) 06-30 00:10:19.211: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:99) 06-30 00:10:19.211: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:137) 06-30 00:10:19.211: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:4745) 06-30 00:10:19.211: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method) 06-30 00:10:19.211: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:511) 06-30 00:10:19.211: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 06-30 00:10:19.211: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 06-30 00:10:19.211: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)


回答1:


It throws a SuperNotCalledException in onStop() which means you did not called super.onStop():

@Override
public void onStop(){
  super.onStop(); // must be called.
}

Every method from the activity lify cycle, such as onCreate(), onResume(), onStart(), etc, should call the super methods.



来源:https://stackoverflow.com/questions/17384958/error-the-application-stopped-when-press-mobile-logout-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!