Android 中的错误“SuperNotCalledException:Activity 没有调用 super.OnCreate()”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3260576/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:19:31  来源:igfitidea点击:

Error in Android "SuperNotCalledException:Activity did not call through to super.OnCreate()"

android

提问by David Prun

uncaught handler:thread main exiting due to uncaught exception android.app.SuperNotCalledException:Activity did not call through to super.OnCreate()

未捕获的处理程序:线程主因未捕获的异常而退出 android.app.SuperNotCalledException:Activity 没有调用 super.OnCreate()

My Code is:

我的代码是:

  public void onCreate(Bundle savedInstanceState) {
        boolean isEnabled = Settings.System.getInt(this.getApplicationContext().getContentResolver(),Settings.System.AIRPLANE_MODE_ON, 0) == 1;


                Settings.System.putInt(this.getApplicationContext().getContentResolver(),Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);

                // Post an intent to reload
                Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
                //intent.putExtra("state",! isEnabled);//Call ON
                try {
                    Thread.sleep(15000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                intent.putExtra("state", isEnabled);
                                                                                           this.getApplicationContext().sendBroadcast(intent);


}

回答by Jorgesys

Add super.onCreate(savedInstanceState);

添加 super.onCreate(savedInstanceState);

 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
        boolean isEnabled = Settings.System.getInt(this.getApplicationContext().getContentResolver(),Settings.System.AIRPLANE_MODE_ON, 0) == 1;
...
...
...

回答by Revan siddappa

add below code in manifest of corresponding activity

在相应活动的清单中添加以下代码

  android:screenOrientation="fullSensor"

This issue happen with 8.0 version with Activity full screen and dialog activity

此问题发生在 8.0 版本的 Activity 全屏和对话框活动中