Libraryless. Click here for Pure Java version (3856L/27K/88K).
1 | !752 |
2 | |
3 | p { |
4 | showBigText("Battery Level", "getLevelLogged", 5000); |
5 | //hideConsole(); |
6 | } |
7 | |
8 | static S ip, level, answer; |
9 | |
10 | static S[] getLevelLogged() { |
11 | S[] s = getLevel(); |
12 | logQuoted("phone-log.txt", "[" + chatTime() + "] Gateway: " + ip + " " + (empty(level) |
13 | ? "Phone not reactive [" + answer + "]" |
14 | : "Phone reactive. Battery level: " + level + " %!")); |
15 | ret s; |
16 | } |
17 | |
18 | static S[] getLevel() { |
19 | ip = gateway(); |
20 | if (empty(ip)) |
21 | ret new S[] { "?", "No gateway found" }; |
22 | |
23 | try { |
24 | answer = sendToPublicCommBot(ip, forward("Battery Bot", "battery level")); |
25 | } catch e { |
26 | answer = exceptionToStringShort(e); |
27 | } |
28 | L<S> tok = javaTok(answer); |
29 | int i = jfind(tok, "<int>%"); |
30 | if (i == 1) { |
31 | level = tok.get(1); |
32 | ret new S[] { level + " pc", level + "% Phone Battery"}; |
33 | } else { |
34 | level = null; |
35 | ret new S[] { "?", "Unknown Phone Battery Level"}; |
36 | } |
37 | } |
Began life as a copy of #1001789
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004082 |
Snippet name: | Show phone's battery level on PC |
Eternal ID of this version: | #1004082/1 |
Text MD5: | a14e660296a13c6d8541e602cc2c7c05 |
Transpilation MD5: | 9cb999152ae9cd1b3ed4e22d662523a6 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-18 15:19:05 |
Source code size: | 917 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 568 / 1108 |
Referenced in: | [show references] |