android中从activity跳转到指定fragment

先跳转到fragement所在的activity,在根据情况判断该显示哪个fragment
 
  

Intent intent = new Intent( this,MainActivity. class);
intent.putExtra( "id", 1);
startActivity(intent);
//singleInstance模式,返回时选择fragment的显示 
  
 
  
protected void onRestart() { Log. e( "zz", "onRestart");
int id= getIntent().getIntExtra("id",  0);
if(id==1){
addFragment( my_f );       showFragment( my_f ); } super.onRestart(); }

你可能感兴趣的:(android中从activity跳转到指定fragment)