Ho creato un nuovo BroadcastReceiver:
public class receiver2 extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Log.d("SECONDO BROADCAST", "RICEVUTO");
}
}
Ora lo registro nel Manifest, dove è già registrato quello vecchio:
<receiver android:name="receiver">
<intent-filter>
<action android:name="android.intent.action.Seconda" />
</intent-filter>
</receiver>
<receiver android:name="receiver2">
<intent-filter>
<action android:name="android.intent.action.Seconda" />
</intent-filter>
</receiver>
Ora uso il sendBroadcast con un Intent che abbia la action comune di ambedue:
Intent intent=new Intent();
intent.setAction("android.intent.action.Seconda");
sendBroadcast(intent);
Vediamo...Ecco il LogCat: come prevedevo, viene eseguita l'azione di ambedue.
04-08 09:31:29.678: D/BROADCAST(2317): RICEVUTO 04-08 09:31:29.727: W/EGL_emulation(2317): eglSurfaceAttrib not implemented 04-08 09:31:29.728: W/OpenGLRenderer(2317): Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6c05880, error=EGL_SUCCESS 04-08 09:31:29.787: D/SECONDO BROADCAST(2317): RICEVUTO
Nessun commento:
Posta un commento