1

I have app with 3 activities.

  1. Main Activity A
  2. Side Activity B
  3. Side Activity C

From Main Activity I can go directly to B and C as well. All moves looks like that:

A->B->C

A->C

A->B

Ofc when I want go back when I'm in C I need to know that I came from A or B and then back to proper one. And that casues me some trobule.

When I go to C acitivity through B, and then back to B onPause is called twice. The point is that when I back like that I need to call recreate (language change)

In C I have variable which tells me that I go from A or B.

Code in C

public void onClick(View v) {
if (v.getId() == R.id.back_button) {
        if(from_B)
           {
               onBackPressed();
           }
        else
           {
               goes_to_A();
            }
}

Code B

@Override
    protected void onResume() {
        super.onResume();
        if(from_B)
        {from_B = false;
            recreate();}

So when I go back to B like that lifecycle looks like: OnResume -> then I call recreate(); -> onPause -> onCreate -> onResume -> onPause! and that last onPause is strange because app should normally work after last onResume. It gives me later errors like

Performing pause of activity that is not resumed

what's wrong with that ?

KyluAce
  • 933
  • 1
  • 8
  • 25
  • this is because you are calling recreate from onResume. Use some kind of delay to call it. – orium Jul 01 '22 at 10:50

0 Answers0