I use the app "Tasker" to accomplish this and it works great. This is how I do it....
I've created a "Task" in Tasker that does these things.... If I am at home or my parents home, the task immediately starts the BI app, otherwise it starts a VPN with my home network and then waits 3 seconds before starting BI (to allow the VPN time to make the connection. This keeps BI from timing out initially). To start this task, I have created a shortcut on my phone's desktop that starts this "connection" task. I use the icon for the BI app as the label for this task so it looks like you are starting the BI app, but instead you run this task. I also have it set up so that anytime you stop using the BI app (either by closing it out, "backing" out of the app, or by opening another app), Tasker will automatically close the VPN connection.
Here is the steps I take to do all of this:
1. Create a "Task" in Tasker (labeled it "View Cameras" ) with these commands:
A. Test Net command (stores the current SSID of whatever WiFi network you are connected to into a variable - if any).
B1. Created an If Statement that if the variable above does NOT equal my home network SSID and does NOT equal my parent's home network SSID (I have a permanent VPN connection between the two locations and therefore don't need to use the VPN when I am at their house)
B2 THEN I autoconnect to my Home VPN connection using OpenVPN that is also installed on my phone.
The commands for that are:
Code:
Action: net.openvpn.openvpn.CONNECT
OR
Action: android.intent.action.VIEW
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:PC {your_profile_name}
Extra: net.openvpn.openvpn.AUTOCONNECT:true
Extra: net.openvpn.openvpn.APP_SECTION:PC
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity
B3 - Wait 3 seconds
B4 - End IF
C. I launch the app
Blue Iris (I am using the paid mobile app on my phone).
2. Created athe desktop shortcut by longpressing on the desktop, choosing "widget" and then "Tasker Shortcut". Then you select the task you created in the first steps (ie View Cameras) to be associated with this shortcut.
3. I have also created a second task that automatically shuts down the VPN connection using these commands:
A. Test Net command (stores the current SSID into a variable)
B1. Created an If Statement that if the variable above does NOT equal my home network SSID and does NOT equal my parent's home network SSID (I have a permanent VPN connection between the two locations)
B2. THEN I disconnect from the VPN connection using this these commands:
Code:
Action: net.openvpn.openvpn.DISCONNECT
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.STOP:true
Extra: {blank}
Extra: {blank}
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity
4. I have created a "Profile" in Tasker called "BlueIris" with the BI app selected and created and "Exit Task" that calls on the VPN disconnect task. This means anytime I close the BI app, or start another app "on top of" the BI app, and I'n not at home or my parents, it disconnects the VPN automatically. This is a very helpful step IMHO because I do not want the VPN open full time - only when I am trying to specifically connect to my home network - and this saves the the trouble of manually disconnecting from the VPN.
Please note -
I do NOT put the "View Cameras" task in as the Enter Task on the "BlueIris" Profile. This would mean if you clicked on the BI app in the app drawer, it would automatically go through the VPN connection steps. However doing it this way means that BI would start before the VPN connection is established and so you have to wait for that connection to time out before trying to reconnect. That annoys me because it isn't done automatically and it obviously takes much longer make all of the connections, so I have chosen to NOT add it as the "Enter Task" and instead use the BI task shortcut as my normal method to access the BI app. Using the method described above with the desktop shortcut means the entire connection process is completely automatic and there is no user input needed unless something goes wrong. Usually because your mobile connection is slower than normal and it doesn't connect before the BI app opens. However if that happens regularly, then simply adjust the Wait time in step 1 to be longer - perhaps 4 seconds instead of 3. 3 seconds works 95% of the time for me, so that's what I use.