how to pass a string to an already opened activity?

Posted by Hossein Mansouri on Stack Overflow See other posts from Stack Overflow or by Hossein Mansouri
Published on 2013-10-22T09:49:36Z Indexed on 2013/10/22 9:53 UTC
Read the original article Hit count: 189

I have 3 Activities A1,A2,A3

A1 call A2 (A1 goes to stack)

A2 call A3 (A2 also goes to stack)

And A3 call A1 (A1 should call from stack not new instance...)

I don't want to Create new instance of A1 just i want to call it from stack

I want to send some Extra String to A1, the problem is here, when i send some String by using putExtra() to A1, A1 can not seen it!

I put getIntent() in onResume() for A1 but it s not working...

Code in A3

Intent in = new Intent(A3.this,A1.class);
in.putExtra("ACTIVITY", "A3");
in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(in);

Code in A1

@Override
protected void onResume() {
  super.onResume();
  if(getIntent().getExtras().getString("ACTIVITY")=="A3"){
     new LoadAllMyOrders().execute();
  }else{
     new LoadAllMyshops().execute();    
  }
}

© Stack Overflow or respective owner

Related posts about android

Related posts about android-intent