In the Service class I wrote this
public void onNotify(TransferHandler<ProcessHolder> handler, int percentage) {
Intent intent = new Intent("PercentageUpdates");
intent.putExtra("percentage", percentage);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
and at the Activity side you have to receive this Broadcast message
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
mMessageReceiver, new IntentFilter("PercentageUpdates"));
By this way you can send percentage to an Activity. here mPercentageReceiver is the class in that class you will perform what ever you want....
private BroadcastReceiver mPercentageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String percentage = intent.getStringExtra("percentage");
if (percentage != null) {
// You can set the percentage here
}
}
};