如何在没有(音乐预览)startActivity 的情况下单击歌曲列表(正在播放 activity)进行播放

How to click song list (Now Playing activity) to playing without (Music Preview) startActivity

如何在main [中点击发送(Intent + putExtras + startActivity) =25=](音乐预览 activity)并在不显示的情况下播放歌曲。 歌曲列表保留,但点击列表歌曲 --> 刷新音乐预览 activity。 我想保留此 activity(歌曲列表),但音乐特权 activity 变得专心,耳目一新并播放新歌。

http://www.pixentral.com/pics/1MpvIjTXByBNfFasIZ0UFI2SbkS11.jpg http://www.pixentral.com/pics/1MpvIjTXByBNfFasIZ0UFI2SbkS11.jpg

歌曲列表:

public void onClick(View v) {

            Intent intent = new Intent(mContext, MusicPreview.class);
            intent.putExtra("pos", position).putExtra("names", SongsName).putExtra("songlist", SongsUri);
            mContext.startActivity(intent);

        }

您可以为此使用 BroadcastReceiver

private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver(){
        @Override
        public void onReceive(Context context, Intent intent) {
            //Get all your music data from the intent
            String position = intent.getStringExtra("pos");
            ...
        }
 };

在你的 NowPlayingActivity 的 onCreate() 中用 Intent 注册这个 BroadcastReciever 像这样,

registerReceiver(mHandleMessageReceiver, new IntentFilter("songchange"));

并且不要忘记注销接收器 onDestroy()

unregisterReceiver(mHandleMessageReceiver);

然后在列表项上的 PlaylistActivity 中单击执行此操作,

Intent intent = new Intent("songchange");
intent.putExtra("pos", position);
...//pass all the needed data
sendBroadcast(intent);