其他分享
首页 > 其他分享> > Android防止快速连续点击跳转

Android防止快速连续点击跳转

作者:互联网

1、创建一个工具类

public class FunctionUtils {
private static long lastClickTime;
public static boolean isFastDoubleClick() {

    long time = System.currentTimeMillis();
    long timeD = time - lastClickTime;
    if (0 < timeD && timeD < 1000) {
        return true;
    }
    lastClickTime = time;
    return false;
    }
}

2、增加判断防止快速点击

if (!FunctionUtils.isFastDoubleClick()) {
                    Intent intent = new Intent(A, B);
                    startActivity(intent);
                }

标签:lastClickTime,FunctionUtils,time,long,点击,static,跳转,timeD,Android
来源: https://blog.csdn.net/weixin_50244933/article/details/123052343