在看ApiDemos中APP/Activity/Reorder Activities这个例子时,ReorderFour这个类中的intent对象加入FLAG_ACTIVITY_REORDER_TO_FRONT 这个Flag,但我把intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);这句话注释掉,也没发现有什么不同啊。
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);
}
};
}
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);
}
};
}
If set in an Intent passed to Context.startActivity(), this flag will cause the launched activity to be brought to the front of its task's history stack if it is already running.
多查android sdk document吧,里面有想要查的大部分东东。
嗯,这个有看,就是不加这个flag,也会转到target的呀。将目标activity放到stack的最上端,莫非这样提高了运行效率?