完全退出程序工具类

    xiaoxiao2021-12-12  2

    package com.dg.user008.killactivity;import android.app.Activity;import android.app.Application;import java.util.LinkedList;import java.util.List;/** * Created by liushu on 2016/11/11. */public class SysApplication extends Application { //运用list来保存们每一个activity是关键 private List mList = new LinkedList(); //为了实现每次使用该类时不创建新的对象而创建的静态对象 private static SysApplication instance; //构造方法 private SysApplication(){} //实例化一次 public synchronized static SysApplication getInstance(){ if (null == instance) { instance = new SysApplication(); } return instance; } // add Activity public void addActivity(Activity activity) { mList.add(activity); } //关闭每一个list内的activity public void exit() { try { for (Activity activity:mList) { if (activity != null) activity.finish(); } } catch (Exception e) { e.printStackTrace(); } finally { //当完全退出时可打开 // System.exit(0); } } //杀进程 public void onLowMemory() { super.onLowMemory(); System.gc(); }}
    转载请注明原文地址: https://ju.6miu.com/read-900336.html

    最新回复(0)