views:

51

answers:

1

Hi All

Activity a =AssumeSomeActivityExists();
Intent openActivity=new Intent();
openActivity.setAction(Intent.ACTION_VIEW);
openActivity.setClass(a,B.class);
a.startActivity(openActivity);

When we do something like above how to make B instance know that it is been called and created by Activity a?

Thanks & Regards
Sudhakar Chavali

+1  A: 

Use extras with your Intent.

Smth like openActivity.putExtra("calledFromA", true)

Then in B:

protected void onCreate(Bundle savedInstanceState) { {
    super.onCreate(savedInstanceState);
    boolean isCalledFromA = getIntent().getBooleanExtra("calledFromA", false);
}
Arhimed