AsyncHandler

AsyncHandler

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

package com.ango.deskclock;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.HandlerThread;

/**
 * Helper class for managing the background thread used to perform io operations
 * and handle async broadcasts.
 */
final class AsyncHandler {

    private static final HandlerThread sHandlerThread =
            new HandlerThread("AsyncHandler");
    private static final Handler sHandler;
    private static Runnable aRunnable;

    static {
        sHandlerThread.start();
        sHandler = new Handler(sHandlerThread.getLooper());
    }

    public static void post(Runnable r) {
        sHandler.post(r);
    }
    
    public static final boolean postDelayed(Context context, Alarm alarm, long delayMillis) {
    	final Context sContext = context;
    	final Alarm sAlarm = alarm;
    	aRunnable = new Runnable() {
            @Override public void run() {
                Intent playAlarm = new Intent(Alarms.ALARM_ALERT_ACTION);
                playAlarm.putExtra(Alarms.ALARM_INTENT_EXTRA, sAlarm);
                sContext.startService(playAlarm);
              }
    	};
    	return sHandler.postDelayed(aRunnable, delayMillis);
    }
    
    public static final void removeCallbacks (){
    	sHandler.removeCallbacks(aRunnable);
    }

    private AsyncHandler() {}
}

        AsyncHandler.post(new Runnable() {
            @Override public void run() {
                handleIntent(context, intent);
                result.finish();
                wl.release();
            }
        });

//        // Play the alarm alert and vibrate the device after 10 seconds so that the user can dismiss or snooze before the alarm alert.
//        Intent playAlarm = new Intent(Alarms.ALARM_ALERT_ACTION);
//        playAlarm.putExtra(Alarms.ALARM_INTENT_EXTRA, alarm);
//        context.startService(playAlarm);
        AsyncHandler.postDelayed(context, alarm, 10000); 

        AsyncHandler.removeCallbacks();  // remove the AsyncHandler.postDelayed(context, alarm, 10000) in AlarmReceiver.java

版权声明:本文博客原创文章,博客,未经同意,不得转载。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117151.html原文链接:https://javaforall.net

(0)
上一篇 2022年1月10日 上午7:00
下一篇 2022年1月10日 上午7:00


相关推荐

  • list列表下嵌套多个list_datalist和select的区别

    list列表下嵌套多个list_datalist和select的区别 aspxviewplaincopytoclipboardprint?%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”DataListNesting.aspx.cs” Inherits=”DataListNesting” %>  >  html xmlns=”http://www.w3.org/1

    2022年10月13日
    6
  • 流程引擎BPM对比[通俗易懂]

    流程引擎BPM对比[通俗易懂]流程引擎就是“业务过程的部分或整体在计算机应用环境下的自动化”,它主要解决的是“使在多个参与者之间按照某种预定义的规则传递文档、信息或任务的过程自动进行,从而实现某个预期的业务目标,或者促使此目标的实现”。通俗的说,流程就是多种业务对象在一起合作完成某件事情的步骤,把步骤变成计算机能理解的形式就是流程引擎。

    2022年10月20日
    4
  • Iocomp Crack和ProEssentials Crack

    Iocomp Crack和ProEssentials CrackIocompCrack和ProEssentialsCrack对于程序员来说,要凭一己之力开发出漂亮逼真的工控仪表和工控图表是非常耗时间和精力的,那么使用专业的第三方控件就是不错的选择,不仅节约开发时间,降低了项目风险,最重要的是第三方控件写的程序更专业,工控图表图像更精细。笔者认为最好用的工控控件当属Iocomp和ProEssentials。下面笔者对这两个工控控件进行了简单的对比评测:Iocomp工控仪表-企鹅578867473Iocomp公司可以说是工业仪表盘控件的龙头老大,在国内工业

    2022年7月25日
    12
  • 智谱上线并开源GLM-4.7

    智谱上线并开源GLM-4.7

    2026年3月12日
    2
  • Rhakorz-piste 05_v2ray官网

    Rhakorz-piste 05_v2ray官网http://rapidgator.net/file/50123356/Odin.Blu-ray.DVD.Ripper.Platinum.v8.7.3-LAXiTY.rar.htmlhttp://ultramegabit.com/file/details/Tf41kOsUINMhttp://uploaded.net/file/5swjjfnj/Odin.Blu-ray.DVD.Ri

    2025年9月27日
    7
  • (8)JMeter元件详解之 Once only Controller 仅一次控制器

    (8)JMeter元件详解之 Once only Controller 仅一次控制器

    2021年7月14日
    166

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号