exit current App - Android App

Android examples for App:App Running

Description

exit current App

Demo Code


//package com.java2s;
import android.app.Activity;

import android.widget.Toast;

import java.util.Timer;
import java.util.TimerTask;

public class Main {
    private static boolean isExit = false;

    public static void exitSystem(Activity activity) {
        if (isExit == false) {
            isExit = true;//from  w ww  . j  a va2 s  .  c  o  m
            Toast.makeText(activity, "hi", Toast.LENGTH_SHORT)
                    .show();
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    isExit = false;
                }
            }, 2000);
        } else {
            activity.finish();
        }
    }
}

Related Tutorials