Receiving Android Google Play Music broadcast twice

最后都变了- 提交于 2019-12-10 10:31:46

问题


I hope you're having a good day :)

Let's get to the point... In my manifest file I have added a receiver like this :

<receiver android:name="com.example.app.AndroidMusicBroadcastReceiver" android:exported="false">
    <intent-filter>
        <action android:name="com.android.music.metachanged" />
    </intent-filter>
</receiver>

I've also created the class com.example.app.AndroidMusicBroadcastReceiver .

public class AndroidMusicBroadcastReceiver extends  BroadcastReceiver {

public AndroidMusicBroadcastReceiver() {
    // TODO Auto-generated constructor stub
}

@Override
public void onReceive(Context arg0, Intent arg1) {


    Log.v("myapp","Artist : "+arg1.getStringExtra("artist"));
    Log.v("myapp","Song : "+arg1.getStringExtra("track"));

  }
}

And it works... But for some reason the Log thing happens twice in a row every time the song changes. Like this :

How come ? Also am I right to assume that my only option if I want to use this information (artist, track) later, is to save it in a file somewhere ?

来源:https://stackoverflow.com/questions/16639935/receiving-android-google-play-music-broadcast-twice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!