Page 1 of 2

App menu when connecting Bluetooth device

Posted: 31 Jan 2018 23:03
by cjt7777
Hi all,

Does anyone know how to get some kind of app selector screen to pop up whenever I connect my Bluetooth headphones? So far the best I can do is to start an app that allows you to select an app but even with that I have to drag down the notifications drawer...

Re: App menu when connecting Bluetooth device

Posted: 01 Feb 2018 12:23
by Desmanto
How many apps do you need? It seems you want only certain apps in the selection choice, it is better to use map values contains the app name and package name for selection. From this keys, use them as the choice in input dialog, then launch the app according to the selected value.


1. Trigger : Bluetooth Device Connected
2. Action : Script, create a map value, Put App name, mapped to their package name. Example :

Code: Select all

app = newMapFromValues(
"Google Music", "com.google.android.music",
"Spotify", "com.spotify.music",
"Musixmatch", "com.musixmatch.android.lyrify");

choice = getMapKeys(app);
3. Action Input dialog : Single choice menu, use the choice as the list values, {choice,listformat,comma}
4. Condition Expression : operation == "ok"
True, go to Action Launch App, false do nothing. This is to protect the launch app, so if you press back or cancel, it won't do anything.
5. Action Launch app, use {app[value]} as the package name.

BTW, do you post the thread in Flow sharing area? Because this subforum is for sharing finished flow.
But somehow it seems there is some error, that makes the thread posted in this subforum (supposed to be in User Help Subforum)

Re: App menu when connecting Bluetooth device

Posted: 01 Feb 2018 21:13
by cjt7777
Wow, that's pretty involved.

Thanks Desmanto. I've followed this as you said but after I select an app it does nothing.

Please see attached screenshot. I just copy and pasted your syntax so I don't know where I've gone wrong.

Thanks

Re: App menu when connecting Bluetooth device

Posted: 01 Feb 2018 21:14
by cjt7777
Also,

Regarding the forum post, that's my error - I posted in 'Flow Sharing' so I'll remember to post in the help sub next time.

Re: App menu when connecting Bluetooth device

Posted: 02 Feb 2018 02:58
by Desmanto
The culprit is the expression. It should be lower case "ok"

Code: Select all

operation == "ok"
Automagic is heavily based on java, which is case-sensitive. Should pay attention to this small detail.

In any case something is not right, you can use condition - debug dialog, to check the value of all variables. This just remind me that I have typed a bug report including the step by step using debug dialog. I should finish it in this 2 days.

Re: App menu when connecting Bluetooth device

Posted: 02 Feb 2018 04:57
by tphg
cjt7777 wrote:Also,

Regarding the forum post, that's my error - I posted in 'Flow Sharing' so I'll remember to post in the help sub next time.
I would be grateful if you could share your completed flow for me to learn the syntax.
Thanks in advance.

Re: App menu when connecting Bluetooth device

Posted: 02 Feb 2018 10:00
by cjt7777
Ah I see,

I was typing ok lowercase but my phone was autocorrecting it to uppercase and I didn't realize this.

Its working perfectly - I just need to customize the apps now. Thanks so much for you assistance Desmanto, this is an huge help to me!!

Re: App menu when connecting Bluetooth device

Posted: 02 Feb 2018 11:49
by cjt7777
Tphg,

I've attached the flow for you, just change the bluetooth device and customize the apps (which I still need to do). I find the package names by going to where they're installed on my phone (android/data/<package name>). Maybe there's an easier way?

Enjoy!

Re: App menu when connecting Bluetooth device

Posted: 02 Feb 2018 13:00
by Desmanto
Hahaha, Autocorrect is toxic for scripting. :D But Autocomplete is fine.

To get the package name, just open the trigger and choose App Package Event. Tap the ellipsis (...) at the Package Name field, wait for the loading and pick any app you want. The result is all the choosen package name separated by comma. Copy this to and press cancel (so you won't overwrite the trigger). Back to your script, paste it and tidy it up. Put corresponding text for the key. The key doesn't have to be exactly as the app name. You can put "Start Google Music", "Start Music", or "Play Music"; as long as the package name is correct to the key you want.

It has been requested to have app picker in input dialog, but I don't think it is going to be implemented soon (since only few user need it). So far, this "App Package Event" method to get the package name is the fastest. There are other triggers can do it too, but "App Package Event" is the first one from above. :) (no scrolling needed). I also don't have the need to select the package name frequently. But if I do, i probably will create a flowception to utilize this "App Package Event" to select the package name.

Re: App menu when connecting Bluetooth device

Posted: 02 Feb 2018 15:06
by tphg
cjt7777 wrote:Tphg,

I've attached the flow for you, just change the bluetooth device and customize the apps (which I still need to do). I find the package names by going to where they're installed on my phone (android/data/<package name>). Maybe there's an easier way?

Enjoy!
@cjt7777,
Thank you so much for your sharing and also thanks to Desmanto for the trick of finding the app package name.