0

I declared my activity as singleTop in the manifest file. I am passing some value with intent when I launching this activity.

Intent i= new Intent(A.this,MysingleTopActivity.class);
i.putExtra("isActive",true);
startActivity(i);

same steps I am doing for restart activity from class B.

Intent i= new Intent(B.this,MysingleTopActivity.class);
i.putExtra("isActive",false);
startActivity(i);

so for this I am getting call in onNewIntent() method of MysingleTopActivity. with isActive =false.

but if I rotate the screen then onCreate() will call and in that "isActive=true".

how can I retrieve current instance value of that activity?

Thanks

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Parth
  • 1,908
  • 1
  • 19
  • 37

1 Answers1

0

For achieving this result need to add

setIntent(newintent); 

in onNewIntent(Intent newintent) {} methold so on rotation of screen newintent will delivered on onCreate();

sample code:

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
//add your code
}
Parth
  • 1,908
  • 1
  • 19
  • 37