Intent的Flags有何作用?该怎么解决
Intent的Flags有何作用?
在看ApiDemos中APP/Activity/Reorder Activities这个例子时,ReorderFour这个类中的intent对象加入FLAG_ACTIVITY_REORDER_TO_FRONT 这个Flag,但我把intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);这句话注释掉,也没发现有什么不同啊。
------解决方案--------------------
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT的意思是,如果task中已经有这个activity A,那么就把A拿到task的最顶层,而不是创建一个新的activity。
所以不加flag也不会影响界面的切过去,只是会影响task的顺序而已。
------解决方案--------------------
------解决方案--------------------
在看ApiDemos中APP/Activity/Reorder Activities这个例子时,ReorderFour这个类中的intent对象加入FLAG_ACTIVITY_REORDER_TO_FRONT 这个Flag,但我把intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);这句话注释掉,也没发现有什么不同啊。
- Java code
public class ReorderFour extends Activity { @Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.reorder_four); Button twoButton = (Button) findViewById(R.id.reorder_second_to_front); twoButton.setOnClickListener(mClickListener); } private final OnClickListener mClickListener = new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ReorderFour.this, ReorderTwo.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); } }; }
------解决方案--------------------
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT的意思是,如果task中已经有这个activity A,那么就把A拿到task的最顶层,而不是创建一个新的activity。
所以不加flag也不会影响界面的切过去,只是会影响task的顺序而已。
------解决方案--------------------
------解决方案--------------------