Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Let's say I want to create a context where the SSID of a wifi connection is either 'ABC' or 'XYZ'. I can see where I am able to create 2 contexts, but it seems to enforce and logic between the two, so in order words I must be in proximity to both 'ABC' and 'XYZ'. I want the context to be either, not both.

share|improve this question

5 Answers 5

up vote 5 down vote accepted

Specify SSID in the WiFi Connected context to be ABC/XYZ This will activate the context if you connect to ABC or XYZ,

Reference: http://tasker.dinglisch.net/userguide/en/matching.html

share|improve this answer

You will need to make a single profile for each context and pair it to the action individually.

share|improve this answer
3  
Hm, this means I won't really be able to have an exit task? –  Zombies Mar 11 '11 at 17:07

You could make your action depend on a variable "%condition=true" and then make two different profiles:

  • profile a: set condition to "true"
  • profile b: set condition to "true"

your profile: if variable "condition"=true then ... and there goes your exit task

But would be nice if the authors would enhance tasker for that... :)

share|improve this answer
    
This method causes problems when the condition may be set true or false by both profile a and b at the same time. For example, I wanted to turn bluetooth on when in a call or in Contacts app. I set %BluetoothNeeded=1 in either case and clear when either case exits. While I'm in a call the Contacts app becomes background and usually gets suspended to save memory, which clears %BluetoothNeeded so bluetooth turns off, cutting my bluetooth headset during the call. –  Chris Dragon Aug 9 at 15:10

Or probably you can use "Inverted" conditions to do an opposite task?, e.g.

If you want to run a task when WiFi is connected OR when the profile:A is inactive, you can instead setup contexts for "WiFi is disconnected" AND "Profile: A is active" both with "inverted" checkbox selected, and setup a task that does the opposite, if that is possible.

This basically works because of:

(A OR B) = NOT((NOT A) AND (NOT B))

share|improve this answer
2  
This answer nice because it's more general. That is, it works with context types other than "Wifi Connected". For example, I wanted to create a profile to put my phone in silent mode whenever it's either docked or connected to my Pebble watch. The easiest way to do this was to make a "not connected to Pebble and not docked" profile that disables silent mode on enter, and enables silent mode on exit. DeMorgan's Laws FTW. –  Laurence Gonsalves Apr 22 '13 at 19:40

To support my bluetooth headset, my desire was to turn bluetooth on when I'm in the Contacts app OR in a call. I could do it only while in a call but then I can't make sure my headset is connected before the other party picks up.

None of the solutions already posted would work. Setting %BluetoothNeeded on when in Contacts or in call means that when a call starts, it sets %BlueToothNeeded on but then when Contacts becomes background to being in call, it sets %BlueToothNeeded off and bluetooth turns off. Using the inverse operation, turn bluetooth off when NOT in Contacts AND NOT in call but turn bluetooth on as an exit task almost works, but apparently Tasker notices the brief period when Contacts loses foreground status and the call hasn't started yet and turns bluetooth off.

So here's what worked for me, based on this blog:

  1. Create a Task called Dummy with an Action of Tasks > Wait > 1ms
  2. Create a Profile called stateInCall with a condition of State > Phone > Call > Type: Any. Link it to the Dummy task.
  3. Create a Profile called stateInContacts with a condition of State > Application > Contacts. Link it to the Dummy task.
  4. Create a Profile called Bluetooth Needed with a condition of State > Variable > Variable Value. Set Name to %PACTIVE, Op to Matches, and Value to *,stateInCall,*|*,stateInContacts,*. According to the Tasker docs, %PACTIVE contains a comma-separated list of active Profiles where the list also begins and ends with a comma to make matching easier. Link this Profile to a Task called Bluetooth On that turns bluetooth on using the Net > Bluetooth > Set: On Action.
  5. Create a Task called Conditional Bluetooth Off with the following Actions:
    1. Task > Wait > 10 seconds
    2. Task > If > %PACTIVE doesn't match *,stateInCall,*|*,stateInContacts,*
    3. Net > Bluetooth > Set: Off
    4. Task > End If
  6. Long press on the Bluetooth Needed Profile then choose Properties. Uncheck Restore Settings.
  7. Quick press the Bluetooth Needed Profile till the Bluetooth On Task appears below it, in the right column. Long press Bluetooth On and choose Add Exit Task, then choose Conditional Bluetooth Off.

Conditional Bluetooth Off will wait 10 seconds before double checking that neither stateInCall nor stateInContacts are true, at which point it will turn bluetooth off. Otherwise, it leaves bluetooth on and when both stateInCall and stateInContacts exit later, it will do its 10 second wait and check again.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.