Hi I have a service for my music player. It contains a broadcastReceiver which updates the seekbar in my activity.I am displaying the song title using this method. I have got the expected results but it is good to update song title and albumArt.If not suggest me a alternative approach for this. Then other question is that how can I save the last played song when the activity is destroyed. I have used sharedPreference.I got the title but I can't set it to Textview. Can you please guide me? Please answer this questions!!! Thank you!
You can defenitly pull the song title out of shared preferences and assign it to your text view. Here is an example:
TextView text = findViewById(R.id.text);
SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
String restoredText = prefs.getString("text", null);
if (restoredText != null) {
String name = prefs.getString("name", "No name defined");//"No name defined" is the default value.
text.setText(name);
}