Execute Android's mediaplayer from an app

sorex

Expert
Licensed User
Longtime User
Hello,

Is there a way to execute Android's default mediaplayer to select a music track and get back to my app by pressing back the back button? (Endomondo does this by the way)

I searched the forum and could find the mediaplayer example but that's for a single track play, invoking the default player would provide me track advance/pause/restart/file selector etc without the need to code all that in my app.

I know I can quit my app via the home button and go to applications > mediaplayer but a simple button that shortcut's this would be neat.
 

NJDude

Expert
Licensed User
Longtime User
Is this what you're looking for?
B4X:
Dim i As Intent

i.Initialize ("", "")
i.SetComponent("com.google.android.music/com.android.music.activitymanagement.TopLevelActivity")

StartActivity(i)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
that didn't work either :(

it spits out this error...

ActivityNotFoundException:No activity found to handle Intent {act=android.intent.action.MUSIC_PLAYER flg=0x20000 }
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
my device is such small Samsung Galaxy Apollo 5800, in some countries it's called Galaxy mini 5800 or something.

I added a button, and put those lines in it's click event, do I need to add something in that manifest to make it working?

Can you attach your example?
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
you mean like this?

B4X:
Dim i As Intent
i.Initialize("PhoneIntents.PlayAudio", "")
StartActivity(i)

fails aswell :(
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
ok, but then I need to code my file selector, retrieve directory to advance tracks etc.

I wanted to avoid that by using that default player.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
Erel:

Do you have any idea how to get this working?

We tried to figure out how Endomondo does it with some intent tracker,
but that didn't bring up anything new.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
you mean there is no general option to use the built-in player so I have to write it all myself (including that ContentChooser as file selector)?
 
Upvote 0
Top