Start PIA VPN when on work wifi ok, exit task not closing the app - Tasker Tips & Tricks

I have a profile "Work Wifi VPN" which is
State Wifi Connected matching SSID
- Trigger Task "Launch App" PIA VPN (which the app automatically connects to the vpn upon opening the app.
- Exit trigger "Launch App"
I can't get the app to close. I tried using a new task to kill the app when not on matching wifi, but that didn't work either. The only thing that happens, is when I'm off the wifi, the app launches again causing it to reconnect to the VPN again.

I use PIA and will have a go to solve it
Sent from my KFFOWI using Tapatalk
---------- Post added at 03:49 PM ---------- Previous post was at 03:28 PM ----------
Only way I can achieve this, is by using secure settings and adding task to reboot the device but I know isn't the best option. But will keep exploring
Sent from my KFFOWI using Tapatalk

apollopayne said:
I use PIA and will have a go to solve it
Sent from my KFFOWI using Tapatalk
---------- Post added at 03:49 PM ---------- Previous post was at 03:28 PM ----------
Only way I can achieve this, is by using secure settings and adding task to reboot the device but I know isn't the best option. But will keep exploring
Sent from my KFFOWI using Tapatalk
Click to expand...
Click to collapse
Thanks, it looks like after some additional searching I can't kill the app without root (non-rooted nexus 6 currently). looks like it may be time to root after all

bigjoejoe said:
Thanks, it looks like after some additional searching I can't kill the app without root (non-rooted nexus 6 currently). looks like it may be time to root after all
Click to expand...
Click to collapse
I'm rooted but yet to solve it. But I'm only a beginner tasker user
Sent from my D6603 using Tapatalk

apollopayne said:
I'm rooted but yet to solve it. But I'm only a beginner tasker user
Sent from my D6603 using Tapatalk
Click to expand...
Click to collapse
I changed my exit task to be a kill app task. There is a checkbox to use root, which of course I can't. I read something about using the OpenVPN tasker plugin for this, but I still think I have to be rooted. oh well, I guess I'll have to keep clicking on disconnect when I leave the office. Thanks for checking!

I've tried the check button of root too but doesn't work. But will try that plugin now
Sent from my D6603 using Tapatalk

I tried the OpenVPN plugin. It seems to only work with OpenVPN. If you only use one server with PIA then this is a legit option - just set up OpenVPN using the settings for that server instead of using PIA's app. The down side to this of course is that you won't be able to automatically connect to the server with the fastest connection.
What I do is a little kludgey, but it works. I use the AutoInput plugin to actually open the PIA app and hit the buttons "Disconnect" and "Stop Killswitch". So basically:
1. Set up a profile for Display Unlock + Not Wifi Connected + %VPN = 1 (I set this to 1 when it initially connects to wifi)
2. Create task called VPN Off
3. Set %VPN to 0
4. Launch app PIA
5. AutoInput Root action (you'll need to record the action and save it to execute it)
6. Say "VPN Off"
There's got to be a more elegant way to do it than this, but for now this is working for me.

I use secure settings, package state, pia, disable. And that stops pia completely.

It's pretty simple actually. I was just browsing through the topics and I noticed this. I realise it's old, but maybe it will help somebody.
This works with any VPN provider. Not just PIA.
You'll need the OpenVPN Connect application: https://play.google.com/store/apps/details?id=net.openvpn.openvpn&hl=en
Install the app, import the OpenVPN configuration files from your VPN provider and give them easy to work with names.
In tasker:
Code:
Profile - State - Net - Wifi Connected (input safe Wifi networks)
Task - Name - VPN Disconnect (you're disconnecting the VPN when using Home Wifi / safe wifi's)
Task: System - Send Intent
Action: android.intent.action.VIEW
package: net.openvpn.openvpn
Class: net.openvpn.openvpn.OpenVPNDisconnect
Target: activity
Exit task
Code:
Name: VPN Connect
Task: System - Send Intent
Action: android.intent.action.VIEW
Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:profile_name_in_openvpn_application (I use the name of the country for the server. example: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:Romania). This is the name of the profile in the OpenVPN application.
Package: net.openvpn.openvpn
Class: net.openvpn.openvpn.OpenVPNClient
Target: Activity
Good luck.

I know that you dont want to trigger exit tasks based on entry tasks as tasker automatically prioritizes and will constantly misfire and fail on the exit task.
instead, make the entry task load the app, and set a timer variable for instance %VPNSHUTDOWN to %TIMES+60 (60 secs in the future) and keep another profile that has a time context to trigger at %VPNSHUTDOWN and that entry task to exit the app AND clear the variable VPNSHUTDOWN. Set the priority high
IF YOU REALLY WANT your exit task to exit the app it just opened set the priority higher than the entry task and change the setting on the task to keep new instances and kill old so it will exit the entry task if it's running and keep the exit

I think you should have mentioned that Package State requires root.

Related

Auto Bluetooth Connection

ADVIANCED USERS ONLY (until I include tutorial)
IMPORTANT: Check the readme file in each folder
Ok, here is some quick Tasker recipes for auto connecting Bluetooth internet. I have not included many instructions, so currently only useful for those familiar with Tasker
I will include a tutorial in the near future
https://www.mediafire.com/folder/ca10g7xz0wd50/Gear
-------------
+++++++++++++++++++++++++
Tutorial in progress
+++++++++++++++++++++++++
Aim:
To setup autoconnection of bluetooth internet connection between Samsung Galaxy Gear and Samsung phone when certain apps are opened
Devices:
Samsung Galaxy S4 (running stock Android 4.3)
Samsung Galaxy Gear (running null v10+)
Apps:
Tasker: https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm (Phone and Gear)
Bluetooth Auto Connect: https://play.google.com/store/apps/details?id=org.myklos.btautoconnect (Gear)
Bluetooth Auto Tethering: https://play.google.com/store/apps/details?id=de.refluxa.android.bat (Phone)
AutoRemote: https://play.google.com/store/apps/details?id=com.joaomgcd.autoremote (Phone and Gear)
Setup AutoRemote:
It is assumed you know how to add devices to your list (http://joaoapps.com/autoremote/)
First you'll need to set it as a bluetooth device by going into Devices in AutoRemote and long preesing, then selecting 'Set Bluetooth Device'
Setup Tasker:
Phone:
You'll need a profile that will turn on the AutoRemote Bluetooth listener when Gear is connected and turn it off when Gear is disconnected
Now we need two more proifles - one to turn off internet and one to turn it back on
Internet on
Internet off
Gear:
You'll need a profile that will turn on the AutoRemote Bluetooth listener when Gear is connected and turn it off when Gear is disconnected
Bluetooth Connected
Code:
Enter Task - AR BT Service ON
Plugin -> AutoRemote Bluetooth
Tick 'Bluetooth Service'
Code:
Exit Task - AR BT Service OFF
Plugin -> AutoRemote Bluetooth
Untick 'Bluetooth Service'
Now we need two more profiles - one to turn off internet and one to turn it back on
On app opening
Code:
Enter Task - Internet On
AutoRemote Message - Add target device name (phone) and message to trigger bluetooth tethering startup on phone
Wait 15 secs - to cover delay
Bluetooth Auto Connect - Profile Networking (PAN) profile, profile action 'Connect'
Flash - Show message on screen that internet is connected
Code:
Exit Task - Internet Off
AutoRemote Message - Add target device name (phone) and message to trigger bluetooth tethering off on phone
Bluetooth Auto Connect - Profile Networking (PAN) profile, profile action 'Disconnect'
Flash - Show message on screen that internet is disconnected
Some suggestions:
- Changing the app exit senario to a time based on so that if you change between various internet capable apps it doesnt turn everything off and then back on again
- Trigger internet off if screen off, then turn back on when screen on
- Tethering always on if power connected
- Use Tasker app factory and create shortcut on homescreen
- Increase screen timeout when connected to internet
Other notes:
- I've turned toasts off on my Gear in AutoRemote settings
- Currently unable to export profiles from Gear, so have included a backup. if restored, it'll clear all settings/profiles/tasks already setup in Tasker on Gear
Recipes:
https://www.mediafire.com/folder/ca10g7xz0wd50/Gear
Brendo said:
ADVIANCED USERS ONLY (until I include tutorial)
IMPORTANT: Check the readme file in each folder
Ok, here is some quick Tasker recipes for auto connecting Bluetooth internet. I have not included many instructions, so currently only useful for those familiar with Tasker
I will include a tutorial in the near future
https://www.mediafire.com/folder/ca10g7xz0wd50/Gear
Click to expand...
Click to collapse
thanks mate will try it out
please can you explain how i can use this i have a the files downloaded i would appreciate it extremely.
salmanaman said:
please can you explain how i can use this i have a the files downloaded i would appreciate it extremely.
Click to expand...
Click to collapse
Perhaps reading the included "README.txt" with the files ?
it doent say how to load these settings on tasker in the readme just says what apps you will need and some code
Use the import? Haven't tried it yet but would assume so
Sent from my GT-N7100 using Tapatalk
Struggling a bit with these myself.. Everything is imported, and Autoremote setup properly... I guess I just don't really understand tasker Any help would be appreciated!
For starters, you need to make sure that you can manually setup Bluetooth tethering
Install required apps
Setup AutoRemote and test that it can communicate both ways with your phone
Import Tasker profiles
Check the profiles to see if they need editing - eg. device names, Bluetooth addresses, apps
Brendo said:
For starters, you need to make sure that you can manually setup Bluetooth tethering
Install required apps
Setup AutoRemote and test that it can communicate both ways with your phone
Import Tasker profiles
Check the profiles to see if they need editing - eg. device names, Bluetooth addresses, apps
Click to expand...
Click to collapse
Yeah I'm in the UK, bluetooth tethering is all good.
So so far I have done:
- set up autoremote on Gear and Phone
- Imported tasker profiles to the phone
- changed the name of the Gear in the Gear connected profile
- Gear internet on/off seem to be setup ok
The Gear connected/disconnected tasks have an exclamation next to them though. Specifically the "Autoremote bluetooth on/off" tasks which don't seem to exist. (are these supposed to be on the Gear?)
The other issue is I can't find a way to restore the userbackup.xml on the Gear :/
I'm guessing my issues are mainly down to not figuring out how to restore the Gear backup #ashamed
Cheers Brendo
---------- Post added at 01:02 PM ---------- Previous post was at 12:59 PM ----------
Scratch that, I'm an idiot. I've restored the tasker backup on the phone, gimme a while to figure it out and I'll update it if I get stuck again
---------- Post added at 01:20 PM ---------- Previous post was at 01:03 PM ----------
Added the two missing tasks \o/ Everything seems setup...
Lets see if this runs...
Brendo said:
For starters, you need to make sure that you can manually setup Bluetooth tethering
Install required apps
Setup AutoRemote and test that it can communicate both ways with your phone
Import Tasker profiles
Check the profiles to see if they need editing - eg. device names, Bluetooth addresses, apps
Click to expand...
Click to collapse
So I have everything set up now I guess. The only issue is the message sent from the Gear to the Note 2 to enable bluetooth tethering.
The gear recognises the phone (and vice versa, they show the ip addressed next to device name), the message just doesn't seem to work :/
Sent from my GT-N7100 using Tapatalk
Finally... Done lol. I didn't start the autoremote listener manually. Doh!
Apologies to all for taking over thisd thread. And apologies to Brendo for being a bit of a noob.
Thanks for adding the profiles
Thank you heaps for this Brendo.
I don't use the internet to browse or facebook on the Gear, the only thing I use it for regularly is to sync my calendar (which updates my Simple Calendar widget).
I just used Tasker on both phone and Gear, BT Auto Tether on the phone, and BT Auto Connect on the Gear.
Used both of the last 2 as plugins in Tasker. Set the phone to turn on BT Tether and Gear to turn on BT connect every hour for 5 minutes.
I just tested it and it works great. I made a test event in my Google calendar and it updated on my Gear homescreen just after the hour without me having to do anything.
5 mins is probably overkill, I think the sync usually takes bout 1 or 2 minutes.
Only problem I had was I had to create the tasks for the Gear on the phone and export them as the Gear screen is too small and you can't select the option to repeat a task. (It shows the start time and end time, but not the repeat option which is in between those 2 fields.
I never used Tasker before, but worth the $3 to have my calendar auto update on the Gear.
Cheers,
Rich
le3ky said:
Finally... Done lol. I didn't start the autoremote listener manually. Doh!
Apologies to all for taking over thisd thread. And apologies to Brendo for being a bit of a noob.
Thanks for adding the profiles
Click to expand...
Click to collapse
Sorry, I was too busy to get on and reply. Good to hear you worked it out. The Bluetooth listener is probably the most common thing to miss (it's new, and not sure documentation mentions it?). Anyway one of the profiles should have triggered the listener so that it isn't on all the time
richlum said:
Thank you heaps for this Brendo.
Only problem I had was I had to create the tasks for the Gear on the phone and export them as the Gear screen is too small and you can't select the option to repeat a task. (It shows the start time and end time, but not the repeat option which is in between those 2 fields.
I never used Tasker before, but worth the $3 to have my calendar auto update on the Gear.
Cheers,
Rich
Click to expand...
Click to collapse
All good. Yes, creating task on watch is tricky due to size and parts missing. Tasker is defs worth the money. It's an awesome bit of software and I 'use' it all the time (don't actually do anything once it is set up )
Brendo said:
Sorry, I was too busy to get on and reply. Good to hear you worked it out. The Bluetooth listener is probably the most common thing to miss (it's new, and not sure documentation mentions it?). Anyway one of the profiles should have triggered the listener so that it isn't on all the time
Click to expand...
Click to collapse
No problem, I eventually changed the bluetooth on, on the phone to be any BT device. Even though I clicked the search to add the Gear it just didn't seem to recognise it :/
Wonder if you might also sanity check something for me, attempting to turn on internet every half hour for 3 mins..
1. Clone the 'Internet off' task, rename 'Internet off - 3 mins'.
2. add a new step before #1, 'wait 3 mins'
3. New Profile > Time >
4. Untick From/To so both say midnight
5. Set repeat to be every 30 mins
6. Add the 'Internet on' task to the profile.
7. Add the 'Internet off - 3 mins' to the profile.
So in this new profile, both tasks have a green tick (no exit scenario). The first one should kick off every 30 mins, as should the second, however the second won't actually do anything for 3 minutes... After 3 minutes is up it should then disconnect..
That look ok? :/
le3ky,
if that doesn't work for you, the way I got BT tethering to turn on for 5 minutes every hour is I set a BT tether on for the phone and BT connect for the Gear every hour starting at 7:00 and finishing at 00:00.
I also set a BT Tether off for the phone and BT disconnect on the Gear every hour starting at 7:05 and ending at 00:05.
It works perfectly to sync my calendar every hour.
You could adjust the times to 3 min and 30 min intervals
I've posted up most of the steps. It still assumes you have an idea about how to use Tasker and AutoRemote
There are some settings you may need to setup such as allowing Tasker external access, device admin rights, etc
Brendo said:
I've posted up most of the steps. It still assumes you have an idea about how to use Tasker and AutoRemote
There are some settings you may need to setup such as allowing Tasker external access, device admin rights, etc
Click to expand...
Click to collapse
Well done Brendo
ok well here i go. i have always seen the value in Tasker but havent used it yet. i like to think i can follow directions and i think as much as i turn on Tether this will be very useful. will report how it works for me as a noob with this.
thanks
fletch33 said:
ok well here i go. i have always seen the value in Tasker but havent used it yet. i like to think i can follow directions and i think as much as i turn on Tether this will be very useful. will report how it works for me as a noob with this.
thanks
Click to expand...
Click to collapse
Be careful! Very easy to become addicted!
Question: Does the listener only need to be activate on the gear ? Or only on the phone ? Or both ?
EDIT: Appears it needs to be enabled on the receiving device, so in our case the phone.. if only it wasn't such a battery hog !

Bluetooth status dependent tasks?

Hi everone,
I am quite new to tasker and I am trying to manage the following:
1. If my phone connects to my car via bluetooth it should enable wifi tethering
2. Once I leave the car and it disconnects it should disable tethering and enable the ordinary wifi again
However, when I leave my car it automatically disables tethering but it does not additionally enable wifi.
I have one profile (bluetooth connection to car) and one task (enable tethering).
I tried adding a decond task enabling wifi, but that will then disable tehtering and stop the first task.
I tried adding a second profile that enables wifi when not connected to car. But that then aaaalways enables wifi even if i manually disabled it.
Tasker automatically disables tethering once the original profile condition no longer applies. But how do I also make it reinstate the wifi status?
Sorry if this sounds too nooby
Could you possibly export the profile and task as an XML file and share it?
Sent from my Nexus 5X using XDA-Developers mobile app
Of course
I think you've done a full backup of your Tasker. I can't import that without overwriting all my data
Instead, export the individual profiles. Tap and hold the profile to highlight, tap the menu button, export.
Sent from my Nexus 5X using XDA-Developers mobile app
Sorry about that
Here's the profile itself.
I tried adding a wifi on/off switch but that will not reinstate the wifi state it had before the profile jumped into action.
Of course I would like tasker to reinstate the wifi status my phone had before the car connected. So off if off and on if on.
Try this
I uploaded the XML file here
https://drive.google.com/file/d/0B8uRFO5wFVFKNW42cnpNOHl0UlU/view?usp=drivesdk
Tasker will set a variable %WIFI_STATUS recording the current wifi status, then enable the hotspot. I then added an exit task which should trigger once your phone disconnects from the car's bluetooth, disconnecting the hotspot and re-enabling wifi if %WIFI_STATUS was set to "on".
Thank you
Would you mind uploading it here instead of google drive? I cannot access it there.
Sure thing. Attached.
Thank you very much!
I have not figured out how you created the second step (red arrow) yet, but I will soon, hopefully
It seems to be working except that sometimes the second step of turning off the tethering and re-enabling the wifi won't work. Maybe this was just a thing of how fast I turned the radio back off. I will try a real life test over the next few days
Most welcome!
Here's how to create an exit task (red arrow)
https://youtu.be/xbB3INzOz1M
You can find more details here.
http://www.pocketables.com/2013/05/beginners-guide-to-tasker-part-1-5-tasker-basics-new-ui.html
Pocketables' 8 part guide is excellent if you have the time you go through it.
As for wifi not always re-enabling, I would suggest increasing the wait time on the exit task from 3 seconds to 5 or even 10. Android automatically disables wifi when you activate tethering, so I figured you would need give the task enough time to be sure the tethering is fully deactivated before enabling wifi again.
I have found that the problem is in fact tether not disabling.
I am trying to write a If task. At the end of which I added a For loop checking whether or not the variables are identical and if not a Goto will jump back to the beginning... or so I hope ^^
OK, now that I have this running, the final remaining problem is the fact that tasker has to run in foreground. otherwise it will not work reliably. is there a way around this?
this issue seems to mainly concern the exit task. the starting task almosz always works but the exit task does not.
is it possible to enable tasker foreground on the starting task and then disable it in the exit task?
edit: i thought of a temporary workaround
since for some reason the starting tasks always work, I end those with opening tasker^^
since I'm driving I do not really care if it is open or not. and the exit task then closes it so it is gone by the time I use my phone again
but if you or anybody knows of a cleaner solution, I would be happy to give it a try
Why don't you want Tasker to run in the foreground? I've never had any noticeable battery drain from leaving that setting on (Preferences > Run in foreground). I've been using Tasker for years and never had to open the app in order to guarantee tasks would run.
If you're on marshmallow you may need to disable Doze for Tasker though, because that can occasionally interfere with the app too.
Are you sure the exit task isn't running at all? I'm assuming you've tested this by having Tasker do something menial at the start of the exit task such as display a notification.
Sent from my Nexus 5X using XDA-Developers mobile app
The problem with running in foreground is that you always have the two lines
"Tasker
1 profile active"
in the dropdown menu. Like a permanent norification. Unless one can disable this dropdown notification and basically just keep the icon, I do not really like it running in foreground.
P.S.: Yes, I made sure the exit task was not running.

Using AutoInput to Exit App on BT Disconnect

I'm new to Tasker and trying to set up a profile that will start my radar detector app when connected to my car's BT, and one that will exit the app when BT disconnects.
I've been successful in creating the profiles that are triggered by the BT connect and disconnect. I've also created the task to start my app on the BT connect. However, I am stuck on how to exit the app when BT disconnects.
The app in question, Esccort Live, can be exited by pressing BACK and clicking on the "OK" prompt. To accomplish this, I trying to use AutoInput to do the following:
1. Press BACK
2. Look for "OK"
3. Click on "OK"
Seems simple, but I can't figure out how to do these three steps.
Also, when using a profile that is triggered by a BT connect or disconnect, is there a way to clear this state once the profile's tasks have been executed?
Any help would be most appreciated.
Jack
Some thoughts for you. You may need to put a pause (e.g. wait 1 sec) since auto input can respond faster than the screen can update. Or flash an alert between the autoinput commands. If the Escort Live app isn't in the foreground when you are trying to make an action on it, try opening recent apps using AutoInput, then reselect the app.
BTW, I'm not sure what you are asking to reset on the BT connect/disconnect. Maybe what you want is to use a variable that is set/unset on connect/disconnect and then that variable triggers your task.

[HELP] Task stuck in a loop performing action on app open

Hey everybody and thanks for taking the time to read this.
I'll explain my problem as clearly as possible:
I created a task with the purpose of opening an app (vpn hosts) and clicking on a button (with autoinput) when I launch twitch or YouTube.
What I was trying to accomplish is that whenever I open said apps my vpn app opens up, activates and then I would like the phone to go back to the original app.
Here comes the problem: I get stuck in a loop cause whenever I go back from vpn hosts to twitch (using autoinput) tasker detects that a profile condition is met and runs again the task.
Is there a way I can force tasker to run those tasks one time and one only?
Hopefully I explained my problem clearly enough to be understood, thanks in advance
Set a cool down period in the profile settings. This will prevent the profile from running again for your specified period.
Less clean, you could also set a variable in the enter task and disable the profile if the variable is set.
Else, use a condition of "not" the vpn app as a trigger condition in the profile.

Chnange audio profiles based on location

Hi
I have installed on my phone the app audio profiles with a tasker plugin
I've created a tasker profile that turn my phone on vibration mode when I'm in a particular location, but now how can I disable vibration when I leave this particular location? Which kind of profile I must create?
If you profile is GPS or cell location then surely you just need to create an exit task. So once the profile isn't true it'll run the exit task, which you can determine what is in there.
Thanks.
So, if I understand, I have to simply long press on my profile (vibration mode) and choose "Add exit activity".
Then after choosen the exit activity my phone will run this activity when I will be not anymore in the profile's location?
copeppe said:
Thanks.
So, if I understand, I have to simply long press on my profile (vibration mode) and choose "Add exit activity".
Then after choosen the exit activity my phone will run this activity when I will be not anymore in the profile's location?
Click to expand...
Click to collapse
Hold on the current entry task and this will give you an option to add in the exit task, so either create new or choose an existing one. Hope you get it sorted out [emoji106]
mgdorbit said:
Hold on the current entry task and this will give you an option to add in the exit task, so either create new or choose an existing one. Hope you get it sorted out [emoji106]
Click to expand...
Click to collapse
hello, i am trying to make a tasker profile that opens a specific application (apk) when the speed drops below 4 kmh only with the GPS because i do not have any sensors. Unfortunately I am still not able to set the variables in the Speed well and if I need a secure setting plugin for the GPS. Can you lead me towards success or advise me how to get started? Thank you
bettuccio said:
hello, i am trying to make a tasker profile that opens a specific application (apk) when the speed drops below 4 kmh only with the GPS because i do not have any sensors. Unfortunately I am still not able to set the variables in the Speed well and if I need a secure setting plugin for the GPS. Can you lead me towards success or advise me how to get started? Thank you
Click to expand...
Click to collapse
I'm afraid I've not looked at any of the GPS settings or functionality. Try a search on the internet, you might find something.
Sent from my SM-G950F using Tapatalk
mgdorbit said:
I'm afraid I've not looked at any of the GPS settings or functionality. Try a search on the internet, you might find something.
Sent from my SM-G950F using Tapatalk
Click to expand...
Click to collapse
something I found but it does not work in practice.

Categories

Resources