My application is giving an Error in the opening file. But this bug is only api 30 channel. This is the fault: Attempt to invoke virtual method 'android.view.WindowInsetsController com.android.internal.policy.DecorView.getWindowInsetsController()' on a null object reference
When I put the application in the Goggle Robo test, it gives the following error. But this error occurs only in the api 30s. It works correctly in other apes. I would be glad if you could help. Thank you.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobilprogramlar.bilmecebahcesi/com.mobilprogramlar.bilmecebahcesi.AcilisEkrani}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.WindowInsetsController com.android.internal.policy.DecorView.getWindowInsetsController()' on a null object reference
FATAL EXCEPTION: main
Process: com.mobilprogramlar.bilmecebahcesi, PID: 13816
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobilprogramlar.bilmecebahcesi/com.mobilprogramlar.bilmecebahcesi.AcilisEkrani}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.WindowInsetsController com.android.internal.policy.DecorView.getWindowInsetsController()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.WindowInsetsController com.android.internal.policy.DecorView.getWindowInsetsController()' on a null object reference
at com.android.internal.policy.PhoneWindow.getInsetsController(PhoneWindow.java:3880)
at com.mobilprogramlar.bilmecebahcesi.AcilisEkrani.onCreate(AcilisEkrani.java:18)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
... 11 more
java.util.ConcurrentModificationException
FATAL EXCEPTION: main
Process: com.google.android.googlequicksearchbox:search, PID: 9903
java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966)
at java.util.LinkedList$ListItr.next(LinkedList.java:888)
at com.google.android.apps.gsa.shared.util.debug.a.g.a(SourceFile:30)
at com.google.android.apps.gsa.shared.util.debug.a.g.a(SourceFile:135)
at com.google.android.apps.gsa.contentprovider.initializer.c.dump(SourceFile:6)
at android.app.ActivityThread.handleDumpProvider(ActivityThread.java:4307)
at android.app.ActivityThread.access$2400(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2013)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
The opening file is the file with the error.
public class AcilisEkrani extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
**final WindowInsetsController insetsController = getWindow().getInsetsController();**
if (insetsController != null) {
insetsController.hide(WindowInsets.Type.statusBars());
}
} else {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.acilisekrani);
// Thread
Thread timer = new Thread() {
@Override
public void run() {
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
Log.i("tago","Zamanlayıcı Çalışmadı");
} finally {
Intent i = new Intent(AcilisEkrani.this,UygulamaUrunlerimiz.class);
startActivity(i);
AcilisEkrani.this.finish();
finish();
}
}
};
// Thread
timer.start();
}
@Override
protected void onPause() {
super.onPause();
finish();
}
}
You probably should call setContentView()
before you try to access the window. According to official documentation, NullPointerException will only be if the is nothing to render.
put your logic inside => onWindowFocusChanged
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowInsetsController controller = getWindow().getInsetsController();
if(controller != null) {
controller.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS);
// controller.setSystemBarsBehavior(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS);
}
} else {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
// make fully Android Transparent Status bar
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With