Choice of Music Players when headphones are plugged in

Post your questions and help other users.

Moderator: Martin

Post Reply
xpeditor
Posts: 1
Joined: 09 May 2013 14:23

Choice of Music Players when headphones are plugged in

Post by xpeditor » 09 May 2013 15:09

Hey Guys,

Automagic is awesome first of all. I'm a couple days in and enjoying it. I'm trying to perform some actions when my headphones are in:

1. Change volume to 7.
2. Present an input dialog menu with a single choice menu of either Pandora or Spotify. Once I figure out how to get it working I'll add two more choices Songza and the native music player app.
3. Script which determines which option was chosen.
4. Launch an app based on the user's choice.

My problem is figuring out which variable to use to perform the check so that I can launch the right app. I'm not sure which variable to use or whether i need to check for a number or the actual string that I put as choices for the input dialog. My script looks like this

if (value = "Pandora")
{
pack = "com.pandora.android";
activity = "com.pandora.android.Main";
}
else
{
pack = "com.spotify.mobile.android.ui";
activity = "com.spoitify.mobile.android.ui.activity";
}

When it comes to launching the app I have {pack} in the package line and {activity} in the class name line.

My log file says "unable to find explicit activity class"

I'm pretty sure the error is in my if statement condition so {pack} and {activity} never get assigned.

Can someone help me figure out in situations like that how to tackle the variable from input dialog. It'll help me out going forward.

Thanks!!!!

tnt1232007
Posts: 2
Joined: 09 May 2013 18:50

Re: Choice of Music Players when headphones are plugged in

Post by tnt1232007 » 09 May 2013 19:29

Yeah, I encountered a similar problem and still have no solution.
I want to make a shortcut that launch a random app every time I click.
I can get a random package name from a list of selected apps (about 50 apps) into a variable but I can not launch it.

I think the problem is the Launch App Action (Package name and Class name) does not support variables.
So it just try to find a package name "{pack}" and error happens.

However in your case the number of apps is 2, maybe you shouldn't use the package variable but make 1 Expression Condition and then 2 Launch App Action.
If you want to add 2 or 3 more choices, I think you can still do this way.

syndromtr
Posts: 31
Joined: 01 Feb 2013 13:28

Re: Choice of Music Players when headphones are plugged in

Post by syndromtr » 10 May 2013 19:13

@xpeditor,
you can check this kind of flow (i'm using similar flow myself, it supports 2+ choices)

> input dialog (single choice) listvalues = pandora, spotify, playerpro, fourthplayer..

> below it, add an expression condition. inside, add this : startsWith(value,"pandora")
> lower side of expression there will be true, false, for true, go below this way: set audio stream volume X, launch app: pandora ...
> false, add another expression condition. inside = startsWith(value,"spotify")
true = spotify ...
false = add another expression condition. inside = startsWith(value,"playerpro")
trıe = playerpro ...

conclusion: create 3 expressions, in other words, check my flow and expand it to right side by adding 2 more expression conditions
http://automagic4android.com/forum/view ... f=3&t=1649

Post Reply