Anybody knows how to use sendBroadcast and BroadcastReceiver for different application? Actually I have already used sendBroadcast and BroadcastReceiver but in the same project. Now I want to try to send to another application. Anybody knows?
In my previous project I broadcast like this in mainActivity:
Intent broadCastIntent = new Intent("SendMessage");
broadCastIntent.putExtra("NAME", gameName);
broadCastIntent.putExtra("JOB",jobStatus);
broadCastIntent.putExtra("STATUS",gameStatus);
sendBroadcast( broadCastIntent );
Log.d("Broadcast sent", gameName );
Also I add method to check the intent:
protected void onResume()
{
if (receiver == null)
{
receiver = new myBroadcastReceiver(); --> Here I call the receiver from another package
}
registerReceiver(reciever, new IntentFilter("SendMessage"));
}
@Override
protected void onPause()
{
super.onPause();
unregisterReceiver(reciever);
}
And in another package but in one project , I have created myBroadcastReceiver class for Receive the intent:
public class myBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent) {
String status = intent.getStringExtra("STATUS");
String job = intent.getStringExtra("JOB");
String media = intent.getStringExtra("MEDIA");
GameWorldExtension.job = job;
GameWorldExtension.media = media;
GameWorldExtension.status = status;
Log.d("receiver", "Got message: " + GameWorldExtension.status);
}
}
I have try and it works fine. Right now I want to try to send into another application. I have tried many ways, but it didn't successful. Anybody knows how to send in right order?Thanks