'stay awake over wifi debuging

I use WiFi ADB Active or ADB Wireless application to debug my build app in eclipse over Wifi instead USB debuging.

how I can keep turn on my device during debug? no options in this application to stay awake.



Solution 1:[1]

When BuildConfig.DEBUG == true, spawn a thread, that calls Debug.WatiForDebugger then get a full wake lock. Periodically poll Debug.isDebuggerConnected(), releasing the wake lock if not.

WaitForDebugger will lock the thread until a debugger is attached (over wifi or not) - if that happens the wakelock will keep the device from sleeping. Once the debugger is disconnected, the next time the background thread checks the status of the debugger, it will release the wake lock and allow the device to sleep again.

Solution 2:[2]

WiFi ADB claims that it does this for you anyway

? Temporarily increase screen-off timeout. Nine times out of 10 this is what users want during development of an Android app and testing it on device. The original screen timeout value is restored when ADB over WiFi is disabled again.

If that automatic screen-off timeout is insufficient, even though you don't need the USB lead in for debugging, you can leave one in attached to a wall wart providing power directly to keep the screen on.

Solution 3:[3]

You can use one of the developer options - "Stay awake". It will keep your screen ON while charging.

Not really what you are looking for I suppose, but close enough

Solution 4:[4]

A quick hack is to add android:keepScreenOn="true" to the main activity (desired activity) layout file root element which will prevent the screen from turning off while working on the app,

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:keepScreenOn="true"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize" />

    </com.google.android.material.appbar.AppBarLayout>
</....>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FunkTheMonk
Solution 2 zmarties
Solution 3 Pavel Dudka
Solution 4 All Іѕ Vаиітy