MKS
MKS

Reputation: 786

Disable switching from app to homescreen android wear

I am running a android wear fullscreen app and after a certain time, the watch switches from app screen to the home screen (shows time). Is there any way to shop the switching. Thanks.

Upvotes: 0

Views: 555

Answers (1)

reVerse
reVerse

Reputation: 35264

I assume by switches from app screen to home screen you mean that the watch goes to sleep / dims the screen. Well you can prevent this by adding the android:keepScreenOn attribute to your layout-file.

For example:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true">

    ...

</FrameLayout>

Alternatively you can add the flag in your Java-Code as well:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

Note: Per default every wear-app will be closed as soon as the screen gets dimmed. A few weaks ago there has been a post on StackOverflow discussing the topic "Long Running Apps on Android Wear". You can find it here along with a pretty neat solution.

Upvotes: 1

Related Questions