
znieh99
Fortgeschrittenes Mitglied
- 12

ich sende mit sendBroadcast einen Intent der von meinem BroadcastReceiver aufgefangen wird. Das mit gesendete Bundle kommt jedoch in der gesendeten Form nicht an. Was mache ich falsch?
Intent vor Senden:

Intent nach Empfang:

Sender:
Code:
public void onClickStart(View v) {
final String s1 = "IS_OK";
final String s2 = "IS_NOT_OK";
final Bundle bundle = new Bundle();
bundle.putString("status1", s1);
bundle.putString("status2", s2);
final Intent broadcastIntent = new Intent(ACTION_BROADCAST_DEMO);
broadcastIntent.putExtra("MSG", bundle);
getApplicationContext().sendBroadcast(broadcastIntent);
}
Code:
@Override
public final void onReceive(final Context context, final Intent intent) {
if (intent.getAction().equals(ACTION_BROADCAST_DEMO)) {
final Bundle bundle = intent.getExtras(); <--- Inhalt ?
String value = bundle.getString("status1", "A"); <-- Default-Wert wird genommen
int a = 1;
}
}
<receiver android:name=".MeinBroadcastReceiver">
<intent-filter>
<action android:name="com.app.heinz.action.BROADCAST_DEMO" />
</intent-filter>
</receiver>