In last two exercise "Detect Battery Level" and "Detect Battery Info", the apps about battery checking have been built. We have to set the battery status on Android Emulator to check our apps. To change the battery status on Android Emulator, Emulator Console can be used.
To connect to the console of any running emulator instance at any time, use this command:
telnet localhost <console-port>
Where <console-port> is the number shown on your emulator.
Details of the usage, refer to the section Using the Emulator Console of the document Android Emulator.
Hi very useful tricks, but I can't find where to set battery status from the console. Can you provide some guidance. Also, if possible, about how to GET status from console.
ReplyDeletethanks a lot
Fabio
hello Fabio,
ReplyDeleteYou cannot change battery status in Eclipse. To change battery status, you have to start a terminal (in Linux), type the command:
$telnet localhost 5554
where 5554 is the number shown on your emulator.
and then type commands, such as:
power display
power ac off
power status discharging
power capacity 25
...
you can type the command help to see the available command.
The setting you changed in console will change the status of Android emulator, so you can GET status by checking Android status.
thanks AndroidEr for this clarification.
ReplyDeleteWhat I was actually trying to achieve is something different - I'd like to monitor battery info directly from the terminal, accessing the battery module, but I wonder if that is ever possbile...
thanks anyway!
hello Fabio,
ReplyDeleteI have no idea for your case, sorry.
But, I wonder what's the purpose. In actual case, real phone is not built inside your system; so detect it for what?
Hi,
ReplyDeletewhat should I do to fix:
'telnet' is not recognized as an internal or external comand, operable program or batch file.
?
Please help.
The app is running, and I've got:
emulator: device fd:640
HAX is working and emulator runs in fast virt mode
creating window 115 127 433 770
emulator: emulator window was out of view and was recentered.
Thanks in advance!