1. Are you ready for the Galaxy S20? Here is everything we know so far!

how to trigger a task by touch a widget toggle?

Discussion in 'Android Apps & Games' started by al ways, Mar 3, 2016.

  1. al ways

    al ways Newbie
    Thread Starter

    I have a widget toggle for google voice+ call back. When I touch it, it will turn voice+ callback on/off. I would like to make sure when it turn on then there is wifi connection or mobile data is turned on.

    1. Download the Forums for Android™ app!


  2. I am not following you ... you want to do something if WiFi or Mobile data is enabled? Try ...

    A1: Test Net [ Type:Connection Type Data: Store Result In:%state ]
    A2: Flash [ Text:%state Long:Off ]

    ... Thom
    #2 Thom, Mar 3, 2016
    Last edited: Mar 3, 2016
  3. al ways

    al ways Newbie
    Thread Starter

    I want the tasker know if voice+ widget toggle is turned on or off and perform tasks according to it.
  4. I just installed that app for this.

    It has a provision toggle enable/disable. I can find no provision to test if it is enabled or disabled.

    As a result, I can not see a way to do what you want.

    ... Thom
  5. electricpete

    electricpete Android Expert

    If you can toggle it with Tasker, then you can build your own widget with Tasker. If you only change the relevant settings with Tasker, then Tasker will "know" the current setting at any time based on what settings Tasker last established (tracked with variables).

    I see Locale used to be able to do this but seems broken:

    Secure settings has some options related to SIP voice which might be the same thing (not sure)
  6. The problem without being able to read the state is ... people make mistakes ... they accidently do something another way ... it gets out of sync and causes a bug that has to be squashed.

    ... Thom
  7. electricpete

    electricpete Android Expert

    That's why I said " If you only change the relevant settings with Tasker..."

    I have a large number of settings that I've turned over to Tasker and never adjust via systems settings. Works fine for me.

    In the case of two state toggles (not the same as op), it allows me to leave a permanent notification whenever I enter the abnormal state which reminds me to turn back to normal. Example
    • usb debug: abnormal = enabled
    • external source: abnormal = enabled
    • brightness: normal = auto; abnormal = manual with max brightness
    I also have turned over on/off control of audio streams to Tasker. I have 6 profiles and 5 of them put a number in my notification which lets me know exactly how many prioritized audio streams are disabled.
    • 0 = no streams disabled
      • for use when alone, not worried about bothering people
    • 1 = notification stream disabled.
      • reduce bothering other people
    • 2 = notification plus (virtual) high-priority notification streams disabled
      • Use this when I sleep while "on call". Keeps ringer open'
      • I built my own "high priority" notification stream in Tasker. If notification listener detects a suitable high-priority notification, it will play a custom sound on the ringer stream provided the last selected menu number was below 2.
    • 3 = all above plus ringer steam disabled
      • Use this when I sleep when not on call. nothing bothers me. Media and alarm remain available)
    • 4 = all above plus media stream disabled
      • meetings. alarm is still enabled, but I can silence it really quick with my watch
    • 5 = all above plus alarm stream disabled
      • church
    • I use the "month days" to display a number 1-5 which instantly lets me know my audio settings. Most of the time when actively using my phone it's in O which is somewhat normal, so nothing displayed in status bar.
    • I still tweak vol level up/down (but not on/off) manually when needed. I use a shortcut which shows 4 sliders in their current values where I can slide as needed. I use the hardware volume keys to tweak level up/dwon when listening to media... I know it will adjust media volume in that context.
    #7 electricpete, Mar 4, 2016
    Last edited: Mar 4, 2016
  8. I have a number that I use ... when I load the system I also have a Tasked profile that sets everything that's important to me to a specific state.

    The problem is that can't be done for the one in question.

    In my experience ... this is frequently referred to as ... an accident looking for a place to happen.

    ... Thom
  9. al ways

    al ways Newbie
    Thread Starter

    Thanks for replies. Let me clarify what I want the Tasker to do.

    The voice+ call back need network connection, but we do not want to keep data service always on.
    Voice+ has a widget toggle.
    When voice+ is off, it display a red cross, if user touch the toggle, then voice+ is turned on, and the toggle display a green check. If touched again, then voice+ is turned off, and the toggle display a red cross again.

    I want the Tasker to turn on data service when user touch voice+ toggle to turn voice+ on, and turn off data service when user touch voice+ toggle to turn voice + off.

    I know the shell command the turn on/off data service: svc data enable (disable), So the only problem is how to trigger Tasker to do it.
    #9 al ways, Mar 5, 2016
    Last edited: Mar 5, 2016
  10. You are now indicating that you are root-ed? On systems 5.0 and newer it is required to toggle data.

    As was pointed out ... you can create a Tasker widget that would do what you want. It can keep set a Global variable to keep track of weather the option is toggled or not and change it each time. Since the state of the option can not be read you would have to make sure it is properly synchronized the first time and then always go through it tot control this activity.

    ... Thom
  11. al ways

    al ways Newbie
    Thread Starter

    Thanks. I have made it work with following task. I don't know how to turn on/off voice+, so I used enable/disable the app.

    CallBack (17)
    A1: If [ %VCB ~ 0 ]
    A2: Run Shell [ Command:svc data enable Use Root:On ]
    A3: Run Shell [ Command pm enable hu.xilard.voiceplus Use Root:On]
    A4: Variable Set [ Name:%VCB To:1 ]
    A5: Set Widget Icon [ Name:CallBack Icon:content://com.android.providers.media.documents/document/image%3A27128 ]
    A6: Else
    A7: Run Shell [ Command:svc data disable Use Root:On ]
    A8: Run Shell [ Command pm disable hu.xilard.voiceplus Use Root:On ]
    A9: Variable Set [ Name:%VCB To:0 ]
    A10: Set Widget Icon [ Name:CallBack Icon:content://com.android.providers.media.documents/document/image%3A27129 ]
    A11: End If

    #11 al ways, Mar 5, 2016
    Last edited: Mar 5, 2016


Tasker Forum


⚙No repetitive tasks for you, let your Android device handle it!⚙
Total Automation, From Settings to SMS. Here are only some
of the things you could do with Tasker. Its real power is the flexibility to combine contexts and tasks however you wish: https://tasker.joaoapps.com/exampleuses.htmlAutomations
Make your phone a true smart
phone! Why remember to change the volume every day when you leave home when your phone can do it for you? Automate stuff based on the app you're in
, the time of day
, your location
, your Wi-Fi network
, Received SMS or Calls
, the currently playing song
and many other (130+) states and events! Check out how easy it is to create an automation: https://www.youtube.com/watch?v=s6EAbLW5WSkActions
350+ actions allow you to truly customize your phone like never before! Send SMS, create notifications, change almost any system setting like Wifi Tether, Dark Mode, Always On Display, change any volume, control Do Not Disturb, open apps, file manipulation, control music playback, get your location... you get the idea. If you can think of it, Tasker can probably do it for you! Note: root is NOT (I repeat NOT) required for majority of the functions.
However, a few of the actions (like the Airplane Mode action and the Mobile Data action on some devices) require root. Regarding those few actions that do require root, this is because of Android security policies that developers cannot work around. ☑ Other Triggers
Manually trigger your actions via launcher shortcuts, quick setting tiles, widgets, long-pressing volume buttons, media buttons (like the ones on your BT headsets or headphones), Bixby button, Navigation Bar, Notificaitons and more! ☑ Join - Remote Tasker
Adding Join (https://play.google.com/store/apps/details?id=com.joaomgcd.join) to the mix will even allow you to trigger tasks from another Android device or PC! ☑ Scenes
Design your own UI and use it to display any info you want or trigger any task! ☑ App Creation
Create your own standalone apps to share or sell with the Tasker App Factory (https://play.google.com/store/apps/details?id=net.dinglisch.android.appfactory)! ☑ Developer Friendly
A lot of 3rd party developers already allow you to perform actions in their apps and listen to their events/states through Tasker! Check out a list of plugins https://tasker.joaoapps.com/pluginlist.html. You can also call most of the Web APIs from Tasker with the powerful HTTP Auth and HTTP Request actions! Check out an example https://youtu.be/yAt2D1XmgUI. ☑ 7 day trial - one time payment to unlock
Get it here: https://tasker.joaoapps.com/download.htmlUseful Links
Starter Guides: https://tasker.joaoapps.com/guides.html Pre-made projects: https://forum.joaoapps.com/index.php?resources/ Official Support Forumhttps://groups.google.com/forum/#!forum/tasker Community full of people willing to help: https://www.reddit.com/r/tasker/ It's not possible to fix problems reported via Play Store Comments so please use the "Report Issue To Developer" option in the app > Menu to do so. Note
: Tasker uses the BIND_DEVICE_ADMIN permission in order to provide the System Lock functionality

February 15, 2020
Last Updated

Share This Page