Instead of passing data indirectly i used the direct way and i set like this in service
Intent intent = new Intent();
intent.setAction(MY_ACTION);
intent.putExtra("DATAPASSED", activeAudio.getTitle());
intent.putExtra("ALBUM_DATA",activeAudio.getAlbum());
sendBroadcast(intent);
in my fragment
@Override
public void onStart() {
super.onStart();
myReceiver = new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(MediaService.MY_ACTION);
getActivity().registerReceiver(myReceiver, intentFilter);
}
private class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
String datapa = arg1.getStringExtra("DATAPASSED");
String datap2 = arg1.getStringExtra("ALBUM_DATA");
Log.d("TITLE OF SONG", datapa);
Log.d("ALBUM", datap2);
textView.setText(datapa);
textView1.setText(datap2);
}
}
Hope this will help some one.
solved passing data from service to fragment giving null point