[Android Apps and Games] Floppen:
Hi, I have been looking for a solution for this problem for quite a while myself, and today I found a way to collect the current value of data transferred and sent on all interfaces. Altho, I will not take credit for this part, nor will I bother to find the original poster, I will however share with you a more detailed explanation on how to set it up, and some ways to make use of it.

First off, this is what will happen

Situation 1. Headphones, Streaming with Spotify - When screen goes off, a variable with the current value of data transferred will be set, after 7 minutes an updated value will be set, we will get the difference between these two and thus get the amount of data transferred, if this is higher than a certain level, nothing will happen! (I.e spotify will continue to stream even tho screen is off)

The reason why I have used 7 minutes is this:Say you put on a song, it is 3 minutes long, after 30 seconds your screen goes off, the song is already downloaded when the traffic calculations will take place, using 7 minutes(or more), will in most cases lead to more than one song being played during the calculation, "ensuring" the capture of traffic data.

Situation 2. Headphones, No stream - Data will turn off after 7 minutes

Situation 3. No headphones, No Stream - Data will turn off after 2 minutes

Situation 4. No headphones, Stream - In my case, data will also turn off after 2 minutes(since this is not an issue for me) if you do however have issues with this, change the point A8 in section 2.2 below

In all cases: If the screen is turned On within the 7 or 2 minutes(depending on situation) the calculation will cancel! (i.e if you are surfing the web and screen goes black during a read)

1. Add some variables (I do not know if this is actually necessary!)

Open tasker, go to the variables tab on the top right corner and press the "+" button in order to add a variable, add these:

%CHEA 0

%CHEAB 0

%DIFF 0

%HEAD Off

2. Add some tasks (In the tasks tab)

-Make a new task called Checknet, press the options button(the screwdrivers) and set Collision handling to: Run both together, and keep device awake: on

Next is the list of what to do, this is not a script, add them one by one manually!

A1: Read Paragraph [ File: /proc/self/net/dev Para:1 To Var:%tet ]

A2: Variable Set [ Name:%newline To:

Do Maths:eek:ff Append: Off ]

A3: Variable Split [ Name:%tet Splitter:%newline Delete Base: Off ]

A4: For [ Variable:%line Items:%tet(3:) ]

A5: Variable Split [ Name:%line Splitter: Delete Base: Off ]

A6: Variable Add [ Name:%rxb Value:%line2 Wrap Around:0 ]

A7: Variable Add [ Name:%txb Value:%line10 Wrap Around:0 ]

A8: End For

A9: Variable Set [ Name:%totalb To:%rxb+%txb Do Maths: On Append: Off ]

A10: Return [ Value:%totalb Stop: On ]

2.1 Add another task and call it Chediff

A1: Add a Perform Task (Found under the Task section) and choose Checknet, make sure to set the "Return Value Variable" value to %CHEA

A2: Add a Wait and set it to 7 minutes (This can be tuned, however you will have issues if you set this too low, I will explain later)

A3: Add another Perform Task, choose Checknet again, and set the "Return Value Variable" to %CHEAB

A4: Add another Wait, I use 2 seconds (For some reason it calculates wrong without this)

A5:Add a Variable set - Set %DIFF to: (%CHEAB-%CHEA)/1000 (Select "Do Maths")

2.2 Add one last task, and call it Dispoff

A1: If %HEAD ~ On

A2: Perform task Chediff

A3: If %DIFF < 1000

A4: Mobile data off

A5: WiFi off

A6: End if

A7: Else

A8: Wait 2 minutes (You could use another "Chediff" (perhaps with a lower waiting walue? Would need to duplicate it tho), but personally I have no reason for it)

A9: Mobile data off

A10: WiFi off

A11: End if

3. Add some profiles

1. On state, hardware, Headset plugged (any) - Variable set %HEAD On

2. On state, hardware, Headset plugged (any) check the invert box - Variable set %HEAD Off

3. On event, Display On - Use 3x stop tasks to stop, Chediff, Dispoff and Chenet

4. On event, Display Off - Perform task "Dispoff"