0

I am going on same activity from two different activities but when i come from Activity_A to Activity_B, i want view visible but when i came Activity_C to Activity_B i want that view visibility gone so how can i achieve this

I tried startActivityForResult() and onActivityResult() like given in below solution

How to set a button visible from another activity in android

But using startActivityForResult() and onActivityResult(), I am not getting visibility visible of view so is there any way to set visibility based on activity from which we are coming.

Vivek Singh
  • 1,142
  • 14
  • 32
YuvrajsinhJadeja
  • 1,383
  • 7
  • 23

1 Answers1

2

You can pass some meta-data to recognize from which activity you are coming.

While going to activity B from activity A

Intent i = new Intent(A.this, B.class);
i.putExtra("some_key","A");
startActivity(i);

While going to activity B from activity C

Intent i = new Intent(C.this, B.class);
i.putExtra("some_key","C");
startActivity(i);

In activity B you can test from which activity you are coming.

String activity = getIntent().getExtra("some_key");

if(activity.equals("C")){
    // hide your view
}
else{
    // show your view
}
Vivek Singh
  • 1,142
  • 14
  • 32