How to communicate between two process /To pass information from one application to another application in android java:
Best ways are intents. whoever wants to send message, He has to raise an intent.Whichever Application wants to receive the message, It has to implement BroadcastStatusReceiver class.
We can raise intent like this...
Intent sIntent = new
Intent(EthernetManager.ETHERNET_STATE_CHANGED_ACTION);
sIntent.putExtra("EthUp",true) //THis is information to be passed
//Intent has different methods for string/int and //so on
whoever[applications] wants to receive this intent they register
this intent in their androidmanifest.xml, they will implement the BroadcastStatusReceiver for the
same.
From the receiver application's BroadcastStatusReciever's OnReceive()
{
if(recvdIntent.Equals(ETHERNET_STATE_CHANGED_ACTION)
{
boolean b=getBooleanExtra("EthUp");
} }
No comments:
Post a Comment