public class ClientExitApplication extends Application { |
private List<Activity> activityList = new LinkedList<Activity>(); |
private static ClientExitApplication instance; |
private ClientExitApplication() { |
|
} |
public static ClientExitApplication getInstance() { |
if ( null == instance) { |
instance = new ClientExitApplication(); |
} |
return instance; |
} |
public void addActivity(Activity activity) { |
activityList.add(activity); |
} |
public void exit() { |
for (Activity activity : activityList) { |
activity.finish(); |
} |
System.exit( 0 ); |
} |
} |
其他Activity中调用 ClientExitApplication.getInstance().addActivity( this ); |
触发退出时嗲用 ClientExitApplication.getInstance().exit(); |