I have an intent service that sends an intent, like this:
Intent result = new Intent("TEST_RESULT");
result.putExtra("MODE", "testing");
sendBroadcast(result);
in another application, the intent gets captured by a broadcast receiver, like this:
receiver registration:
IntentFilter testResultIntentFilter = new IntentFilter("TEST_RESULT");
TestResultReceiver receiver = new TestResultReceiver();
this.registerReceiver(receiver,testResultIntentFilter);
onReceive method in the receiver:
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getStringExtra("MODE");
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
this code fails on the getStringExtra call with null pointer exception, it's as if the putExtra method is ignored. I tried everything but nothing works.