Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.ActivityManager;
import android.content.Context;

public class Main {
    /**
     * Exit current app(clear memory). This util needs
     * `android.permission.KILL_BACKGROUND_PROCESSES` permission.
     *
     * @param context context
     */
    public static void exitApp(Context context) {
        if (context == null) {
            return;
        }

        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        manager.killBackgroundProcesses(context.getPackageName());
        System.exit(0);
    }
}