【发布时间】:2020-07-09 00:06:05
【问题描述】:
我在我的应用程序中使用了底部导航。我有 2 个菜单项(主页、搜索)。每次用户尝试从其他活动切换回家庭活动时,我都不想重新启动家庭活动。我尝试在我的意图中添加 FLAG_ACTIVITY_REORDER_TO_FRONT 但它不起作用。
搜索活动
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.home:
Intent intent = new Intent();
startActivity(new Intent(getApplicationContext(),MainActivity.class));
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
overridePendingTransition(0,0);
return true;
case R.id.search:
break;
return false;
}
});
【问题讨论】:
-
你的意思是家庭片段不是活动?
-
我没有使用家庭碎片。实际上我是android开发的新手。我只使用活动
标签: android android-intent android-activity bottomnavigationview