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

时间:2010-07-15 22:23:54

标签: android

  

未捕获的处理程序:由于未捕获的异常,线程主要退出   android.app.SuperNotCalledException:Activity没有通过调用   super.OnCreate()

我的代码是:

  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);


}

2 个答案:

答案 0 :(得分:25)

添加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;
...
...
...

答案 1 :(得分:3)

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

  android:screenOrientation="fullSensor"

此问题发生在带有活动全屏和对话活动的8.0版本