App menu when connecting Bluetooth device

Share and discuss your flows and ideas with other users.

Moderator: Martin

cjt7777
Posts: 19
Joined: 09 Aug 2016 12:50

App menu when connecting Bluetooth device

Post by cjt7777 » 31 Jan 2018 23:03

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...

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: App menu when connecting Bluetooth device

Post by Desmanto » 01 Feb 2018 12:23

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)
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

cjt7777
Posts: 19
Joined: 09 Aug 2016 12:50

Re: App menu when connecting Bluetooth device

Post by cjt7777 » 01 Feb 2018 21:13

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
Attachments
Screenshot_20180201-210813.png
Screenshot_20180201-210813.png (168.85 KiB) Viewed 28927 times

cjt7777
Posts: 19
Joined: 09 Aug 2016 12:50

Re: App menu when connecting Bluetooth device

Post by cjt7777 » 01 Feb 2018 21:14

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.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: App menu when connecting Bluetooth device

Post by Desmanto » 02 Feb 2018 02:58

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

tphg
Posts: 57
Joined: 17 Apr 2017 05:31

Re: App menu when connecting Bluetooth device

Post by tphg » 02 Feb 2018 04:57

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.

cjt7777
Posts: 19
Joined: 09 Aug 2016 12:50

Re: App menu when connecting Bluetooth device

Post by cjt7777 » 02 Feb 2018 10:00

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!!

cjt7777
Posts: 19
Joined: 09 Aug 2016 12:50

Re: App menu when connecting Bluetooth device

Post by cjt7777 » 02 Feb 2018 11:49

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!
Attachments
flow_Flow2_20180202_100108.xml
(3.23 KiB) Downloaded 1262 times

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: App menu when connecting Bluetooth device

Post by Desmanto » 02 Feb 2018 13:00

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

tphg
Posts: 57
Joined: 17 Apr 2017 05:31

Re: App menu when connecting Bluetooth device

Post by tphg » 02 Feb 2018 15:06

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.

Post Reply