Android每隔一分钟发出时间更新广播

AndroidBroadcastReceiver大约 446 字

每隔一分钟时间改变了就会发送该广播

Intent.ACTION_TIME_TICK
  • 动态注册广播
IntentFilter filter=new IntentFilter();
filter.addAction(Intent.ACTION_TIME_TICK);
registerReceiver(receiver,filter);
  • 接收广播
private BroadcastReceiver receiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(Intent.ACTION_TIME_TICK)) {
          //刷新UI
        }
    }
};
阅读 747 · 发布于 2019-04-09

————        END        ————

扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看换一批