1. Download our Official Android App: Forums for Android!

General 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
    Rank:
    None
    Points:
    28
    Posts:
    35
    Joined:
    Dec 5, 2014

    Dec 5, 2014
    35
    12
    28
    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.
     

    Advertisement

  2. Thom

    Thom  
    VIP Member
    Rank:
    None
    Points:
    1,618
    Posts:
    12,114
    Joined:
    Feb 16, 2011

    Feb 16, 2011
    12,114
    5,021
    1,618
    Male
    Software Developer
    Keene, NH USA
    I am not following you ... you want to do something if WiFi or Mobile data is enabled? Try ...

    Test
    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
    Rank:
    None
    Points:
    28
    Posts:
    35
    Joined:
    Dec 5, 2014

    Dec 5, 2014
    35
    12
    28
    I want the tasker know if voice+ widget toggle is turned on or off and perform tasks according to it.
     
  4. Thom

    Thom  
    VIP Member
    Rank:
    None
    Points:
    1,618
    Posts:
    12,114
    Joined:
    Feb 16, 2011

    Feb 16, 2011
    12,114
    5,021
    1,618
    Male
    Software Developer
    Keene, NH USA
    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
    Rank:
     #52
    Points:
    393
    Posts:
    2,104
    Joined:
    Jan 7, 2012

    Jan 7, 2012
    2,104
    1,055
    393
    Male
    Electrical Engineer
    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:
    https://play.google.com/store/apps/details?id=com.steelgirder.LocaleGVSettingsPlugin&hl=en

    Secure settings has some options related to SIP voice which might be the same thing (not sure)
     
  6. Thom

    Thom  
    VIP Member
    Rank:
    None
    Points:
    1,618
    Posts:
    12,114
    Joined:
    Feb 16, 2011

    Feb 16, 2011
    12,114
    5,021
    1,618
    Male
    Software Developer
    Keene, NH USA
    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
    Rank:
     #52
    Points:
    393
    Posts:
    2,104
    Joined:
    Jan 7, 2012

    Jan 7, 2012
    2,104
    1,055
    393
    Male
    Electrical Engineer
    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. Thom

    Thom  
    VIP Member
    Rank:
    None
    Points:
    1,618
    Posts:
    12,114
    Joined:
    Feb 16, 2011

    Feb 16, 2011
    12,114
    5,021
    1,618
    Male
    Software Developer
    Keene, NH USA
    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
    Rank:
    None
    Points:
    28
    Posts:
    35
    Joined:
    Dec 5, 2014

    Dec 5, 2014
    35
    12
    28
    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. Thom

    Thom  
    VIP Member
    Rank:
    None
    Points:
    1,618
    Posts:
    12,114
    Joined:
    Feb 16, 2011

    Feb 16, 2011
    12,114
    5,021
    1,618
    Male
    Software Developer
    Keene, NH USA
    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
    Rank:
    None
    Points:
    28
    Posts:
    35
    Joined:
    Dec 5, 2014

    Dec 5, 2014
    35
    12
    28
    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

Share This Page

Loading...