I can't get an answer to the following questions, so please let me ask you a question as well.
https://stackoverflow.com/questions/27767657/android-up-navigation-targetting
Aa→Ab(Fa)→Ac: Pattern 1
↓↑
Ab(Fb) → Ad
↓↑
Ab(Fc) → Ac: Pattern 1
Notification→ Ac: Pattern 2
External Application → Ac: Pattern 2
Is there a general way to determine the transition destination?
The current implementation passes the values to determine the transition source as follows:
However, if the Up-Navigation target screen cannot be determined, it feels redundant to write this kind of code in all cases.
/*ActivityC.java*/
public static void launch (Context context, String from) {
Intent = new Intent(context, ActivityC.class);
// from —A unique value for each item in ViewPager
int.putExtra(EXTRA_FROM, from);
context.startActivity(intent);
}
How to determine the transition destination of Up-Navigation is as follows, but how
is originally used.
Should it be implemented?
If there are many screens transitioning from ViewPager or URI Scheme, the following code will increase:
/*ActivityC.java*/
@Override public boolean onOptionsItemSelected(MenuItem){
switch(item.getItemId()){
case android.R.id.home:
if(!getIntent().hasExtra(EXTRA_FROM)){
// Consider transitioned via Notification or URI Scheme
// I don't know if I'm going to transition to Ab(Fa) or Ab(Fc), so I'm going to fix it to Ab(Fa).
Intent upIntent=ActivityB.createIntent(this,null);
TaskStackBuilder.create(this)
.addNextIntent(ActivityA.createIntent(this))
.addNextIntent (upIntent)
.startActivities();
finish();
} else{
// consider transitioning from within this app
String from = getIntent().getStringExtra(EXTRA_FROM);
Intent upIntent=ActivityB.createIntent(this,from);
NavUtils.navigateUpTo(this,upIntent);
}
}
return true;
}
At first, I thought it would be easy to write on AndroidManifest.xml, but in reality, I often encounter this kind of screen transition pattern, so I asked if there were any best practices.
android
For each pattern, define another activity derived from Ac (Ac1, Ac2, Ac3 extensions Ac) and make it different on Manifest, and it will be refreshing on Manifest.
© 2024 OneMinuteCode. All rights reserved.