Open Activity previously created without reloading

1

Activity A called Activity B and C.

Intent intent_mapa = new Intent(getApplicationContext(), ActivityB.class);
intent_mapa.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent_mapa);

Intent intent = new Intent(getApplicationContext(), ActivityC.class);
startActivity(intent);

then Activity C calls me to Activity D.

 Intent intent = new Intent(getApplicationContext(), ActivityD.class);
    startActivity(intent);

Activity D calls ActivityB without reloading the WebView, ActivityB has a WebView and I do not need to recharge my url.

Intent intent = new Intent(getApplicationContext(), ActivityB.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);

When we reorder back we open Activity D again.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {


    Intent intent = new Intent(getApplicationContext(), ActivityD.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(intent);
    return false;
}

The problem is that Activity B is opened at least twice because it is called from Activity A and Activity D.

How to do so that is called from different Activity open me only once ????

    
asked by Sergio Andres Moreno Herrera 24.03.2017 в 21:37
source

1 answer

0
  

How to make it so that it is called from different Activity open me   only once ????

when you define your Activity within AndroidManifest.xml define the property

android:launchMode="singleInstance"

Example:

<activity android:name=".MyActivity"
              android:launchMode="singleInstance">

with this you would force only one instance of the Activity to be created.

    
answered by 24.03.2017 / 23:57
source