I'm looking for a way to send global media action (Play/pause, Next, Previous) to the phone, much like it can take it froma bluetooth paired radio/speaker.
I have found the MediaController class (http://developer.android.com/reference/android/widget/MediaController.html) but it seem more to be to implement the receiver of those action and i'm looking for a sender.
However, I can't seam to find any reference to this anywhere in the android doc...
Anyone already stumble on this ?
On the Settings > Privacy > Permission manager > Files and media page, each app that has the permission is listed under Allowed for all files. If your app targets Android 11, keep in mind that this access to "all files" is read-only.
Android uses the action ACTION_SEND to send data from one activity to another, even across process boundaries. You need to specify the data and its type. The system automatically identifies the compatible activities that can receive the data and displays them to the user.
Manage downloaded music, movies, and podcasts The biggest space suckers on your Android phone are media files. Those albums that you downloaded for a camping trip or a movie for a long plane ride that you simply forgot about can eat up lots of data.
Shared storage: Store files that your app intends to share with other apps, including media, documents, and other files. Preferences: Store private, primitive data in key-value pairs. Databases: Store structured data in a private database using the Room persistence library.
So if your activity is called MainActivity
you can do:
//for play/pause toggle Intent i = new Intent("com.android.music.musicservicecommand"); i.putExtra("command", "togglepause"); MainActivity.this.sendBroadcast(i); //for next Intent i = new Intent("com.android.music.musicservicecommand"); i.putExtra("command", "next"); MainActivity.this.sendBroadcast(i); //for prev Intent i = new Intent("com.android.music.musicservicecommand"); i.putExtra("command", "previous"); MainActivity.this.sendBroadcast(i); //to change volume audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, *value*, AudioManager.FLAG_SHOW_UI);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With