I'm trying to pass an int value from my Service to the CallReceiver class, unfortunately the CallReceiver.value always equals 0, even after set with another value. When I'm trying to pass it as a parameter to the constructor situation is exactly the same, and so with the setter methods called from service. Is there really no way to pass there any data?
Service:
SharedPreferences settings = getSharedPreferences("SETTINGS", 0);
int value = settings.getInt("value1", 0); // here the correct value is present, not 0.
CallReceiver mCallReceiver = new CallReceiver();
CallReceiver.value = value;
Receiver:
public class CallReceiver extends BroadcastReceiver {
public int value;
public CallReceiver(int value) {
this.value = value;
}
public CallReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
Log.v("value", String.valueOf(value)); // here "value" = 0.
}
}