warning: [deprecation] FLAG_TURN_SCREEN_ON in LayoutParams has been deprecated

Reference:

https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_TURN_SCREEN_ON

This statement is deprecated from API level 27, so you can safely manage this situation with:

Adding the FLAG_TURN_SCREEN_ON flag to the flags of the current window typically happens in the onCreate event and BEFORE the method SetContent() of an activity; after the deprecation, instead, you have to call the setTurnScreenOn(boolean) method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT < 27) // the old version
        getWindow()
            .addFlags(
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            );
    else  // the new version
         setTurnScreenOn(true);

    setContentView(R.layout.main_activity);
}

Leave a Reply

Your email address will not be published. Required fields are marked *