Skip to content Skip to sidebar Skip to footer

Keeping Screen On, Which Way?

I have found two ways on keeping the screen on: First one is simpler: getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCRE

Solution 1:

You should see Coding for (Battery) Life Google IO presentation, slide 16

If you don't want to, then: You could do the first one in the XML for any layout element and it is the suggested one to use (don't know about applying it to the window though, might be as bad as the wakelock, I don't know).

XML:

<LinearLayoutandroid:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"android:keepScreenOn="true">

Window Flag:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

Post a Comment for "Keeping Screen On, Which Way?"