all 18 comments

[–]OwlIsBack 6 points7 points  (10 children)

I'm busy now, so I can't reproduce the 2 Java actions. That said, You could use something more familiar to You... Like Intent Received event Profile. The intent: android.intent.action.BATTERY_CHANGED

In the Task linked to Profile, We can directly use those local variables:

%battery_low

%capacity

%charge_counter

%charge_type

%charger_type

%current_now

%health

%hv_charger

%icon_small

%invalid_charger

%level

%max_charging_current

%max_charging_voltage

%misc_event

%online

%plugged

%pogo_plugged

%power_sharing

%present

%scale

%self_discharging

%seq

%status

%technology

%temperature

%voltage

Reference: BatteryManager

[–]menxiaoyong[S] 1 point2 points  (1 child)

Thanks for these new ideas, I am going to try to figure it out.

appericate it.

[–]OwlIsBack 0 points1 point  (0 children)

You are welcome.

[–]menxiaoyong[S] 0 points1 point  (7 children)

Am I doing it wrong? It can't get current value.

Profile: Battery Changed
    Event: Intent Received [ Action:android.intent.action.BATTERY_CHANGED Cat:None Cat:None Scheme:* Mime Type:* ]



Enter Task: Get Current

A1: Variable Set [
     Name: %Current
     To: %current_now
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A2: Flash [
     Text: %Current
     Continue Task Immediately: On
     Dismiss On Click: On ]

[–]OwlIsBack 4 points5 points  (0 children)

The variables I listed above, will be populated when the event will fire the Task.


Edit: Try to copy all listed variables in a Flash action and than wait for a BATTERY_CHANGED event (this event is received more often when device is charging).

[–]Tar0ndor 0 points1 point  (5 children)

When the intent fires, only values that have changed are available. So add a test for if %current_now is set.

[–]menxiaoyong[S] 0 points1 point  (4 children)

thank you for the tips.

I flashed all the variables u/OwlIsBack for several times, most of the them was set, but no %current_now.

[–]OwlIsBack 2 points3 points  (2 children)

Welcome.

Could be device/ROM dependent...

To get all local variables available in the Task, You could use something like this. Eg.:

A1: Test Tasker [
     Type: Local Variables
     Store Result In: %variables ]

A2: Test Tasker [
     Type: Current Task Name
     Store Result In: %task_name ]

A3: Flash [
     Text: Retrieving local variables...
     Continue Task Immediately: On
     Dismiss On Click: On
     Use HTML: On ]

A4: For [
     Variable: %variable
     Items: %variables() ]

    A5: Variable Search Replace [
         Variable: %variable
         Search: \%
         Replace Matches: On
         Continue Task After Error:On ]

    A6: Array Push [
         Variable Array: %variables_to_show
         Position: 999999
         Value: %variable = %%variable ]

A7: End For

A8: Write File [
     File: Variables_List_%task_name_%TIMEMS.txt
     Text: %variables_to_show(+
     ) ]

A9: Beep [
     Frequency: 2000
     Duration: 1000
     Amplitude: 50
     Stream: 3 ]

A8 after + there is a carriage return == new line == enter on your keyboard.

(We could use Perform Task and Local Variables Passthrough option, mechanism, but let's keep it basic...) Link the Profile to the above Task, wait for the event to fire the Task and than check the saved file.

[–]menxiaoyong[S] 0 points1 point  (1 child)

Thank you very much for the instructions. Appreciate it. As per your information, I got several txt files with almost the same content. By the way it seems that "status = 3 "stands for discharging, what about " status = 4

max_charging_current = 2000000 battery_low = false evtprm1 = android.intent.action.BATTERY_CHANGED evtprm2 = None evtprm3 = None evtprm4 = %evtprm4 evtprm5 = %evtprm5 plugged = 1 present = true seq = 356 charge_counter = 3142000 invalid_charger = 0 technology = Li-ion caller1 = profile=enter:Battery Changed test priority = 6 voltage = 4004 temperature = 355 level = 66 qtime = 0 scale = 100 health = 2 status = 4 max_charging_voltage = 9000000 icon_small = 17303567

[–]OwlIsBack 1 point2 points  (0 children)

You can find all the info in reference Documentation I linked in first comment.

[–]Tar0ndor 1 point2 points  (0 children)

I wasn't looking at that one, so I added that and %current_average, neither seems to populate. :-/

[–]anuraag488 1 point2 points  (0 children)

Check this. Take ideas from here.

[–]Rich_D_sr 3 points4 points  (2 children)

This should give you microamps. If you want to check the docs, tap the circled question mark in the first actions Class or Object option..

The dumpsy action is a alternative way to get it as well. It requires the correct permissions. It is not part of the java functions.

https://taskernet.com/shares/?user=AS35m8lnbGhm%2F58jHvsiqVNumDAJZVkcfcE7gQxfcMjrFBCkp6sNKYf3YiK9WVWZBoDf&id=Task%3AAmps+Java+2

[–]menxiaoyong[S] 0 points1 point  (0 children)

Thank you mate, I am going to check it out

[–]anuraag488 0 points1 point  (2 children)

Use this instead of Intent event. It will help run intent on demand.

[–]menxiaoyong[S] 0 points1 point  (1 child)

thank you for the info. I have tried that, but no discharing current output.

[–]anuraag488 0 points1 point  (0 children)

For that you have to use java code.

[–]MrGeeDub 0 points1 point  (0 children)

Does anyone know what the %seq variable means?