Page 1 of 1
How to alternate/switch apps ?
Posted: 26 Nov 2016 15:55
by ltplenus
Here's is my scenario.
I have youtube and maps opened/running... I'm using proximity sensor as the trigger and a dialog box to allow me to select the application I want to bring to front. So..how to do it/switch them automatically without any manual input ?
I know some conditions and expressions must be used but I don't really know how.
Thanks !
Re: How to alternate/switch apps ?
Posted: 26 Nov 2016 23:58
by P-chu
Hi itplenus,
First thing that comes to my mind to suggest would be to use a global variable to indicate which app you are currently using. The variable name needs to start with "global_", so you could call it "global_runningapp" for example. Then you could use the action "Script" to set and update the global variable, and the condition "Expression" to check which state/value the variable is at. Also, when you start your two apps, you will want to set the initial value to the global variable (or reset the initial value when you stop your proximity flow).
A little more complex (maybe) is to use one or two condition "App Task Running"s to see if one of your two apps is running in the foreground. Mind you, I've been getting the impression that this condition box may not work with everyone. Anyway, the obvious follow-up is to launch (even if already in background) or bring to foreground the other app. If the first "App Task Running" had been false, then you could either assume that the other app is in the foreground (and follow-up accordingly), or do a check on the other app.
Hope these suggestions are usable for you.
Re: How to alternate/switch apps ?
Posted: 28 Nov 2016 00:27
by ltplenus
Thanks a lot P-chu !
Would it be too much to ask for you to post a flow ?
Re: How to alternate/switch apps ?
Posted: 01 Dec 2016 00:09
by P-chu
Well, ltplenus, this should not be too difficult for you to make if you already have created a flow with a dialog box. However, you first need to determined how you want your device/phone to know when to switch app and to which app if it is important for certain situations. If not dialog box, then a widget on the home page? A floating (aka "overlay") widget or button? A fixed notification in the statusbar? Orientation or shaking of phone (though it may not be reliably responsive enough)? What is the "why" and "when" you want to switch apps?