How to pick an app on Bluetooth connection?

Post your questions and help other users.

Moderator: Martin

Post Reply
leadhex
Posts: 10
Joined: 01 Jul 2015 20:18

How to pick an app on Bluetooth connection?

Post by leadhex » 02 Jan 2019 21:12

I would like a simple way to chose a Music player to launch on Bluetooth connection. If it can be hands off that would be more ideal. At one point I thought I had something setup, but I can't seem to remember how to set this up.
Any samples floating around?

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

Re: How to pick an app on Bluetooth connection?

Post by Desmanto » 03 Jan 2019 17:48

I remember have ever created the choice with input dialog. But can't find it anywhere anymore.
The trigger is Bluetooth device connected, pick your deivce. Then you can use input dialog to show the app choice and launch that.

Create a script ot map all the app name and package name. Add/change the name and package name with your music player. You can find the package name in the launch app action.

Code: Select all

app = newMapFromValues(
"Joox", "com.tencent.ibg.joox",
"PowerAmp", "com.maxmpz.audioplayer",
"Spotify", "com.spotify.music");

choice = getMapKeys(app);
Use input dialog - Single Choice Menu, and put {choice,listformat,comma} as the list values.
Put condition expression to protect the back/cancel

Code: Select all

operation == "ok";
Then use launch app and use {app[value]} as the package name. (edited : Previously I state as {choice[value]}, which is wrong)
Last edited by Desmanto on 17 Jan 2019 17:18, edited 1 time in total.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190512, Pie 9.0, Rooted.

leadhex
Posts: 10
Joined: 01 Jul 2015 20:18

Re: How to pick an app on Bluetooth connection?

Post by leadhex » 04 Jan 2019 14:09

Thanks for the code. After it ran I received the following error:

Code: Select all

Error: Could no get launch intent for package {error}.
Please define a class
Las executed: Action Launch App: {choice[value]}
For the script I put:

Code: Select all

app = newMapFromValues(
"Plex", "com.plexapp.android",
"PlayMusic", "com.google.android.music");

choice = getMapKeys(app);
Also, I'm not seeing where to insert the following:
Put condition expression to protect the back/cancel

Code: Select all

operation == "ok";

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

Re: How to pick an app on Bluetooth connection?

Post by Desmanto » 06 Jan 2019 10:47

Oh, sorry. I don't state the exact element clearly. Here is list :

Trigger : Bluetooth device connected
Action : Script, the script above
Action : Input Dialog - Single Choice Menu, put the {choice,listformat,comma} for the list value.
Condition : Expression, operation == "ok";
Action : Launch App, use {app[value]}
Last edited by Desmanto on 17 Jan 2019 17:18, edited 1 time in total.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190512, Pie 9.0, Rooted.

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

Re: How to pick an app on Bluetooth connection?

Post by cjt7777 » 17 Jan 2019 11:31


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

Re: How to pick an app on Bluetooth connection?

Post by Desmanto » 17 Jan 2019 17:21

@cjt7777 : Thanks, I really forgot that thread. That's why I remember ever posted it. Seems after a year, my answer still very similar :lol: The only thing is I made mistake about the {choice[value]}, which I probably started to use the method last year.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190512, Pie 9.0, Rooted.

Post Reply