Most of my development devices have OLED displays, so they can't safely have "Stay Awake" enabled under "Developer Options" (I've ruined WAY too many devices using it in the past). But having to continuously keep picking up the device to hit the power button every time I re-launch something within Android Studio is driving me insane.
Is there any way to configure the devices and/or Android Studio to allow the screen to time out and turn off as usual, but automatically turn it back on again whenever I do something via ADB?
For what it's worth, I tried disabling lockscreen security, but launching a program or debugging session via shift-f9 or shift-f10 while the screen of the ADB-connected device is off still fails to turn it on.
Before starting the app, run
adb shell input keyevent KEYCODE_POWER
to wake up the device
write this code in Oncreate and before Setcontentview :
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
screen will never sleep with this code.
Related
I have a scenario where I want an app to open when it detects that it's connected to a USB device. I have used an approach similar to this (it is using a USB_DEVICE_ATTACHED intent-filter and I have the ID's defined in an xml) and it is working for the most part. The problem I'm having is that when the Android Tablet powers on, the tablet will already be connected to the USB device, so the app doesn't get the USB_DEVICE_ATTACHED event. This then requires me to start the app manually after power up, which leads to me getting this unwanted dialog screen each time:
Allow App to access USB?
[ ] Always open App when USB is connected
Cancel OK
It makes no difference if I check the "Always open" box. It still shows up each time. I have tried using a broadcast receiver to open the app when the app powers on, and I still get the dialog window.
So I'm wondering:
Is there is a way to see get a USB_DEVICE_ATTACHED event when I first power on?
Or is there a way to not display the unwanted dialog screen each time I open the app manually?
I would really appreciate any suggestions. Thanks!
The next command enables phone call recording in OnePlus phones (may be others too):
adb shell settings put global op_voice_recording_supported_by_mcc 1
But after reboot its effect is disabled. My phone is OnePlus 6T.
How to make this setting persistent?
jOnePlus Tools is an answer. This application sets settings up on every reboot.
https://forum.xda-developers.com/oneplus-5/themes/app-enable-call-recording-boot-t3634292
This link has other root-required methods you might want to try.
Unfortunately, I am also trying to find a way without root. As the setting automatically turns off, sometimes before reboot, when you have an active some-country sim card, my hypothesis is that there is a "checking" program going on under the hood. If there is an adb command to turn off that "checking", the result should be permanent.
I also have a 6T, and what I could see about what causes recording to be disabled, is any application installation made by PlayStore.
If you keep the automatic update function of the applications deactivated, the recording remains activated, but anytime you do any installation on the PlayStore, the recording will be disabled and you will need to enable it with the command again.
I have a Android device which I keep connected with my Jenkins server(through USB) which basically run my automation every day at a specified time but every now and then I keep running into problems where device starts to loose charge overnight or when I am remotely accessing(Vysor) the device and run some automation tests on it , it starts to loose and eventually die down. I am looking for suggestion to keep my device up and running 24/7 without loosing charge when I am running my automation cases.
I had tried all of the options you mentioned. I am now using powered USB hub which keeps it charging on power 24/7.
There are some things that you can do to keep your Android device from going to sleep.
enable developer mode (I assume you have done that already since you
are running automatic tests).
on settings->developer menu turn USB
debugging on (again I assume this is already done)
on settings->developer menu turn on Stay Awake so that the display
never goes to sleep when the device is charging.
It may also be that the issue is with your device. In that case I suggest you try the same thing with some mainstream Android phone and see if the behavior differs.
I use Eclipse for programming my android device. I connect the device to my computer via USB. Everything is fine but I write some code that can take a bit long time and I pressed F11, my device had already gone to sleep and its screen had gone to off. At every turn, I have to press its button to wake it up. If I make its screen time-out longer in the settings, then my device becomes very hot.
Is there any solution which can provide that it can turn its screen on to show my application when I press F11. It may be a code piece that I can temporarily add into my application during development phase or a setting adjustment for my device.
Thanks
By expanding to Tushar's comment,
Go to Settings,
Select Developer Options,
you will see following screen, Tick the "USB Debugging" option
You can set the screen to never timeout when plugged in/charging. This is available through Settings > Developers Options (or Advanced Settings).
I'm Developing an Android Application where it's constantly required to keep the App up an running at all time. with the phone connected to a power outlet at all time, Is it possible that if the phone's battery died to Auto-start up the app with no user intervention . *i.e to power up the phone automatically without hitting any power button and start up android since charger is connected. *
then start up my app with android.intent.action.BOOT_COMPLETED and RECEIVE_BOOT_COMPLETED permission
PS: I have tried android.intent.action.ACTION_POWER_CONNECTED but it only works if the phone is already powered up.
I have exactly same requirement as yours.
Can we plan a solution like this:
The Android device is always connected to charger's output.
Charger's power supply is connected to a custom made hardware device which controls power supply to charger.
This hardware device puts charger off until battery is getting low. i.e. 20% remaining.
Once battery is less than 20%, that device automatically switch on the charger.
The "custom made hardware" gets it input from android device itself via USB/WiFi/Bluetooth.
Just a thought. May not be practically possible.
No way doing it if you do not root your device and add reboot scripts to the programs running to show battery charging pictures when device is turned off and charging.for Samsung s2 here is an answer
Maybe you can make an additional app that waits for the BOOT_COMPLETED with its BroadcastReceiver and then check wether the power is connected and start as a new Intent your application?
Just a quick thought..
I have the same problem.
The solution that i will to implement:
1.- get out two(here is my doubt, ¿what two wires?, because i see three, i will use my multimeter for see continuity between wires when i push the button) wires from the power button phone.(when you push that button, it just connect two poles like a switch).
2.- When you have the two wires, so, we build a little circuit with a timer like a 555(integrated circuit). The purpose of the circuit will connect the two wires(from power button phone) by a 5 seconds period every 15minutes.
Obviously this circuit will be running always.