java 背景助手

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 背景助手相关的知识,希望对你有一定的参考价值。

// From: https://stackoverflow.com/questions/8384067/how-to-dismiss-the-dialog-with-click-on-outside-of-the-dialog

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

/**
 * Background Helper
 */
public class BackgroundHelper {
    // region ATTRIBUTES =========================================================

    private static Timer mActivityTransitionTimer;
    private static TimerTask mActivityTransitionTimerTask;
    private static boolean isBackground;
    private static final long MAX_ACTIVITY_TRANSITION_TIME_MS = 2000;

    // endregion =================================================================

    // region METHOD =============================================================

    /**
     * start Activity Transition Timer
     */
    public static void startActivityTransitionTimer() {
        mActivityTransitionTimer = new Timer();
        mActivityTransitionTimerTask = new TimerTask() {
            public void run() {
                isBackground = true;
            }
        };

        mActivityTransitionTimer.schedule(mActivityTransitionTimerTask,
            MAX_ACTIVITY_TRANSITION_TIME_MS);
    }

    /**
     * stop Activity Transition Timer
     */
    public static void stopActivityTransitionTimer() {
        if (mActivityTransitionTimerTask != null) {
            mActivityTransitionTimerTask.cancel();
        }

        if (mActivityTransitionTimer != null) {
            mActivityTransitionTimer.cancel();
        }

        isBackground = false;
    }

    /**
     * The app is in Background
     *
     * @return is background or not
     */
    public static boolean isInBackground() {
        return isBackground;
    }

    // endregion =================================================================
}

以上是关于java 背景助手的主要内容,如果未能解决你的问题,请参考以下文章

VA助手亮显背景

VA助手亮显背景

VA助手亮显背景

Java小聪明编程IWrite粘贴小助手——YouWrite

Java小聪明编程IWrite粘贴小助手——YouWrite

(简单)Ror:在视图中创建助手。但是怎么做?