Restarting Phone when it is shutdown - java

Is there any way to start the phone automatically after every 'n' minutes after shutdown... I am developing a solution for this but not getting any success. Any help or link to the solution will be highly recommended. Thanks in advance.

You can not turn the device on from an app on the device, for the obvious reasons. There is however a way to boot the device from the computer.
If the device had usb debugging turned on, you can use adb and run adb reboot to boot the device connected by usb to the computer.

Related

Working in android studio. My mobile apears offline while I try to run the app

I keep getting this bug where my mobile appears offline when I try to run/debug my app in Android Studio.
I have searched the internet for some help. I tried the following things:
Remove cable -> reinsert the cable.
Remove cable -> Remove app from mobile -> reinsert the cable.
Restart pc.
Restart mobile.
Exit ADB.
uncheck USB debugging -> recheck USB debugging.
Revoke USB debugging authorization.
Try other USB port.
Sometimes one of this steps works. Most of the time nothing happens, and I lose so much time to this issue.
Does anyone know why my phone goes offline? And does someone know a permanent fix for this issue? its really annoying.

Android studio devices

Once or twice a day Android Studio doesn't recognize any devices attached to my computer. Even
adb devices
doesn't show anything. The only thing that makes my devices reappear is restarting my computer. Even
adb kill-server
adb start-server
doesn't show any devices. Does anybody know why and how I can make adb recognise my devices without restarting my computer?
Something strange with my USB port I reckon. Reinserting the cable mostly fixes the problem.
check lsusb , if your cable or usb port have problem your device does not appear
otherwise if you see your device in list and your adb devices is empty, maybe the problem is adb files config, check your VENDOR ID in adb_usb.ini , the VENDOR ID must be same as lsusb id

How to start an app on reboot if USB_HOST_ATTACHED and ACTION_BOOT_COMPLETED

I'm writing an app that needs to start up automatically when a device is connected to a tablet in USB Host Mode. In addition to that I want my app to start on tablet reboot after boot_completed if the usb device is attached. Having need to implement these two functionalities I'm in a bit of a dead lock situation. It works all fine when I plug a usb device the app brings up itself without a problem. but on reboot i'm running in to an issue where the application starts itself before the boot_complete is recieved, and that is because the usb device is already attached to the tablet. This is made worse in kitkat 4.4.2 as they have delayed processing the boot_complete state by doing it serially where as 4.3 did it parallely on reboot.
So how can I get the app to start on reboot after bootup is completed rather than before boot_up is completed while having the USB device attached.
Many thanks

Android Device not detecting in ecclips

I have installed all required drivers of mobile. My device is able to detect in' adb device'. but while running application, my mobile device is not coming..
In "device" it is able to locate.
I have gone through: "Run-> Run Configuration-> target" but there is no any active device.
yeah, I experienced that too. The reason can be anything... Try updating you adb / usb drivers. Maybe you gonna need a vendor-specific usb-driver.
Last time when I had problems with detecting my Sony Xperia S, I solved them by turning USB Modem in Preferences on.
this issue solved...
I changed SDK folder with another latest version of SDK externally.
Restarted Computer. Configured device.

Bluetooth Android issue

I am running a multi thread application on android and adobe air, in native android 2 bluetooth sockets are set up and a couple of server threads for the air app to communicate with the bluetooth sockets of native android. It's basically socket programming and it all works on one device I used to programme it.
The device i used to develop this app was slow, i therefore got myself another tablet to test (android vega) and it is very fast at communicating my bluetooth data as it has 2.1edr version.
The problem is with the Advent Vega tablet the bluetooth streams just disconnect for no apparent reason intermittently and in the adb log window i just get trying to connect to device all of a sudden when the disconnect occurs, i have no mention of the crash anywhere in the log, this happens to both bluetooth connected threads at the same time so it must be something to do with the bluetooth radio im suspecting. The other tablet device runs the app fine but slower (no disconnects). I have even installed a custom 3.0 rom on the vega to see if it was a os problem but the disconnect problem persisted on 3.0 as well.
Due to the fact there is no mention of this in the adb log i am just basically staring at a screen with no idea of why it disconnects for 2 days now!! The only way to get the app to run again after this disconnection occurs is to restart the bluetooth on the device but this disconnect occurs again eventually when next run. It seems to improve the amount of time it stays alive tansferring data when the app is first run afater a re boot.
I have gone through all code of the run() and stopping() of each thread and it seems to exit gracefully, i close the bluetooth sockets only, it seems from research no need to close the bluetooth input and output but i have also tried that approach to closing.
Can anyone offer suggestions as to why both bluetooth read/write loops would just stop all of a sudden and disconnect? Seemingly effecting the adb log as well as it just says trying to connect...
Or any suggestions as to how to better debug when this occurs?
Or even what somebody else would do in this situation.
Hope someone can help, i have a great phone remote app for the android tablet owner community and it hinges on this final issue which i have been stuck on for 2 days.
I had problems with disconnects, and implemented a keepalive by sending a ping request and a ping ack.
This worked fine for me...

Categories