19

uncaught handler:thread main exiting due to uncaught exception android.app.SuperNotCalledException:Activity did not call through to 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);


}
Artiom
  • 7,694
  • 3
  • 38
  • 45
David Prun
  • 8,203
  • 16
  • 60
  • 86

2 Answers2

33

Add 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;
...
...
...
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
6

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

Revansiddappa
  • 708
  • 1
  • 7
  • 16
  • 1
    Had the same issue with Android 8.0. Setting the screenOrientation to fullSensor fixed it. (For whatever reason it does not work with "portrait" mode). – MW. Jul 27 '18 at 08:55
  • 1
    Yes fullSesor works, but then orientation doesn't remain portrait, I want to force it to portrait. Can you help? @Manuel – Asad Ali Choudhry Nov 19 '20 at 07:32