I work with a service that extends MediaBrowserServiceCompat , and also has MediaSessionCompat.Callback() with its overridden methods, including onPlayFromMediaId() .
Inside the fragment that has a recyclerview when the recyclerview element is clicked, the following code is called. As you can see from the image, it is clear that mediaId , as well as songBundle have values ββand are passed to the onPlayFromMediaId() method.

It is strange that inside the Service class, where the playFromMediaId() method is overridden, it receives only the value for the string variable mediaId , and the songBundle magically becomes empty. (Note: the key used to place and receive the argument is also the same. The original songsVO is a POJO that implements the Parcelable interface.)

In addition to this other interesting thing that I noticed, I return to the snippet called onPlayFromMediaId() later after executing it, and check the values ββof each variable except mediaId every other variable becomes zero.

RecyclerAdapter Class
class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> { @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View itemView = inflater.inflate(R.layout.layout_song_item, parent, false); return new ViewHolder(itemView); } @Override public void onBindViewHolder(ViewHolder holder, final int position) { holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) {
TL; onPlayFromMediaId(String, Bundle) only passes the String variable, while the bundle is empty.
Link- This tutorial
android android-service android-mediaplayer
Darshan miskin
source share