开发者

How to stop the launch of a thread done with postDelayed

开发者 https://www.devze.com 2023-02-05 16:43 出处:网络
I ha开发者_开发知识库ve a service tha launch a thread after 15 sec. This is a snippet of my code:

I ha开发者_开发知识库ve a service tha launch a thread after 15 sec. This is a snippet of my code:

        Handler mHandler = new Handler();
        OverclockThread ocThread = new OverclockThread();
        ocThread.ocPreference = readPreference("oc");
        ocThread.serviceOn = true;

        if (Intent.ACTION_SCREEN_ON.equals(action)) {
            ocThread.screenOff = false;
            mHandler.postDelayed(ocThread, 15000);
        }

Now I'd like to add the ability to stop the launching of my ocThread before these 15 seconds...for example by pressing a button or a checkbox...which command I have to use to stop a thread launched with postDelayed?

thanks

simone


I'have used:

mHandler.removeCallbacks(ocThread);
0

精彩评论

暂无评论...
验证码 换一张
取 消