I have three fragment in an Activity C. they are behaving as tabs. I have to go from a fragment to a new Activity X. Now i want to come back to fragment from Activity X.
enter image description here
@Override
public void onBackPressed() {
//Here "digiM" is an Actionbar Title
if(getTitle().equals("digiM") || getSupportActionBar().getTitle().equals("digiM"))
{
//reload the activity if you want to open it again as your need
Intent intent = new Intent(Your_Current_Activity.this,Your_Current_Activity.class);
startActivity(intent);
}
}
If you have action bar in that fragment, then you can check action bar title on onBackPressed() in Activity which contains method like.