Duliba Ionut
Duliba Ionut

Reputation: 53

Prevent Screen Saver From Appearing on Android TV

I have a product that is a web app running on android wrapped app on TVs. Over time the app is timing out and going to screen saver.

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

        setContentView(R.layout.activity_main);
        startWebview();
        Objects.requireNonNull(getSupportActionBar()).hide();
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        generateUniqueIdentifier();

    }

I have added getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); but screen saver still appears

Also in

  @Override
    protected void onResume() {
        super.onResume();
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        if (mWebView != null) {
            mWebView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }

    }

Is there a way to stop the screen saver from going on?

Upvotes: 0

Views: 171

Answers (0)

Related Questions