вы ищете Brodcast Reciver:
действие A должно отправить brodcast:
public class ActivityA extends Activity
{
private void sendStringToActivityB()
{
//Make sure to have started ActivityB first, otherwise B wont be listening on the receiver:
startActivity(ActivityA.this, ActivityB.class);
//Then send the data
Intent intent = new Intent("someIntentFilterName");
intent.putExtra("someKeyName", "someValue");
sendBroadcast(intent);
}
}
, а действие B должно реализовать получатель:
public class ActivityB extends Activity
{
private TextView mTextView;
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
String strValueRecived = intent.getStringExtra("someKeyName","defaultValue");
mTextView.setText(strValueRecived);
}
};
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mTextView = (TextView)findViewById(R.id.textView);
registerReceiver(mBroadcastReceiver, new IntentFilter("someIntentFilterName"));
}
}
пример не завершен, но вы можете прочитать об этом по ссылке: http://developer.android.com/reference/android/content/BroadcastReceiver.html