FLAG_ACTIVITY_BROUGHT_TO_FRONT
FLAG_ACTIVITY_CLEAR_TASK
FLAG_ACTIVITY_CLEAR_TOP
FLAG_ACTIVITY_CLEAR_WHEN_TASK_REST
FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
FLAG_ACTIVITY_FORWARD_RESULT
FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
FLAG_ACTIVITY_MULTIPLE_TASK
FLAG_ACTIVITY_NEW_TASK
FLAG_ACTIVITY_NO_ANIMATION
FALG_ACTIVITY_NO_HISTORY
FLAG_ACTIVITY_NO_USER_ACTION
FLAG_ACTIVITY_PREVIOUS_IS_TOP
FLAG_ACTIVITY_REORDER_TO_FRONT
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
FLAG_ACTIVITY_SINGLE_TOP
FLAG_ACTIVITY_TASK_ON_HOME
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.android.test" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".ReorderOnLaunch" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".ReorderTwo" /> <activity android:name=".ReorderThree" /> <activity android:name=".ReorderFour" /> </application> <uses-sdk android:minSdkVersion="9" /> </manifest>
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, ReorderOnLaunch!</string> <string name="app_name">ReorderOnLaunch</string> <string name="reorder_on_launch">This is the first of a sequence of four Activities. A button on the fourth will use the Intent.FLAG_ACTIVITY_REORDER_TO_FRONT flag to bring the second of the activities to the front of the history stack. After that, proceeding back through the history should begin with the newly-frontmost second reorder activity, then the fourth, the third, and finally the first.</string> <string name="reorder_launch_two">Go to the second</string> <string name="reorder_two_text">This is the second in a sequence of four Activities.</string> <string name="reorder_launch_three">Go to the third</string> <string name="reorder_three_text">This is the third of a sequence of four Activities.</string> <string name="reorder_launch_four">Go to the fourth</string> <string name="reorder_four_text">This is the last in a sequence of four Activities.</string> <string name="reorder_second_to_front">Bring the second in front</string> </resources>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip" android:gravity="center_horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0" android:paddingBottom="4dip" android:text="@string/reorder_on_launch"/> <Button android:id="@+id/reorder_launch_two" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/reorder_launch_two" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip" android:gravity="center_horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0" android:paddingBottom="4dip" android:text="@string/reorder_two_text"/> <Button android:id="@+id/reorder_launch_three" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/reorder_launch_three" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip" android:gravity="center_horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0" android:paddingBottom="4dip" android:text="@string/reorder_three_text"/> <Button android:id="@+id/reorder_launch_four" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/reorder_launch_four" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip" android:gravity="center_horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0" android:paddingBottom="4dip" android:text="@string/reorder_four_text"/> <Button android:id="@+id/reorder_second_to_front" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/reorder_second_to_front" /> </LinearLayout>
package my.android.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ReorderOnLaunch extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reorder_on_launch);
Button twoButton = (Button)findViewById(R.id.reorder_launch_two);
twoButton.setOnClickListener(mClickListener);
}
private final OnClickListener mClickListener = new OnClickListener(){
public void onClick(View v){
startActivity(new Intent(ReorderOnLaunch.this, ReorderTwo.class));
}
};
}
package my.android.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ReorderTwo extends Activity {
@Override
protected void onCreate(Bundle saveState){
super.onCreate(saveState);
setContentView(R.layout.reorder_two);
Button twoButton = (Button)findViewById(R.id.reorder_launch_three);
twoButton.setOnClickListener(mClickListener);
}
private final OnClickListener mClickListener = new OnClickListener(){
publicvoid onClick(View v){
startActivity(new Intent(ReorderTwo.this, ReorderThree.class));
}
};
}
package my.android.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ReorderThree extends Activity {
private final OnClickListener mClickListener = new OnClickListener(){
public void onClick(View v){
startActivity(new Intent(ReorderThree.this, ReorderFour.class));
}
};
@Override
protected void onCreate(Bundle saveState){
super.onCreate(saveState);
setContentView(R.layout.reorder_three);
Button twoButton = (Button)findViewById(R.id.reorder_launch_four);
twoButton.setOnClickListener(mClickListener);
}
}
package my.android.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
publicclass ReorderFour extends Activity {
@Override
protected void onCreate(Bundle saveState){
super.onCreate(saveState);
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);
}
};
}
package net.oschina.app;
import java.util.Stack;
import android.app.Activity;
import android.content.Context;
/**
* activity堆栈式管理
*/
public class AppManager {
private static Stack<Activity> activityStack;
private static AppManager instance;
private AppManager() {}
/**
* 单一实例
*/
public static AppManager getAppManager() {
if (instance == null) {
instance = new AppManager();
}
return instance;
}
/**
* 添加Activity到堆栈
*/
public void addActivity(Activity activity) {
if (activityStack == null) {
activityStack = new Stack<Activity>();
}
activityStack.add(activity);
}
/**
* 获取当前Activity(堆栈中最后一个压入的)
*/
public Activity currentActivity() {
Activity activity = activityStack.lastElement();
return activity;
}
/**
* 结束当前Activity(堆栈中最后一个压入的)
*/
public void finishActivity() {
Activity activity = activityStack.lastElement();
finishActivity(activity);
}
/**
* 结束指定的Activity
*/
public void finishActivity(Activity activity) {
if (activity != null && !activity.isFinishing()) {
activityStack.remove(activity);
activity.finish();
activity = null;
}
}
/**
* 结束指定类名的Activity
*/
public void finishActivity(Class<?> cls) {
for (Activity activity : activityStack) {
if (activity.getClass().equals(cls)) {
finishActivity(activity);
break;
}
}
}
/**
* 结束所有Activity
*/
public void finishAllActivity() {
for (int i = 0, size = activityStack.size(); i < size; i++) {
if (null != activityStack.get(i)) {
finishActivity(activityStack.get(i));
break;
}
}
activityStack.clear();
}
/**
* 获取指定的Activity
*/
public static Activity getActivity(Class<?> cls) {
if (activityStack != null)
for (Activity activity : activityStack) {
if (activity.getClass().equals(cls)) {
return activity;
}
}
return null;
}
/**
* 退出应用程序
*/
public void AppExit(Context context) {
try {
finishAllActivity();
// 杀死该应用进程
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
} catch (Exception e) {
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有