Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android通知时间格式如何更新?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在使用自定义RemoteView for AndroidNotification,我想模仿系统行为.

Android如何更新其通知时间格式 – 设置后是否会更改?我怎么能模仿这种行为?

最佳答案
鉴于您自己提供了答案,我不确定您是否还在寻找答案.但是,如果您希望实现原始目标,则可能需

>每当时间发生变化时重建RemoteView(它更容易)
>设置BroadcastReceiver以捕获时钟的滴答,以便您知道时间何时发生变化.

所以,有些代码有点像这样:

class MyCLeverThing extends service (say) {

    // Your stuff here

    private static intentFilter timeChangeIntentFilter;
    static {
        timeChangeIntentFilter = new IntentFilter();
        timeChangeIntentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
        timeChangeIntentFilter.addAction(Intent.ACTION_TIME_CHANGED);
    }

    // Somewhere in onCreate or equivalent to set up the receiver
    registerReceiver(timeChangedReceiver,timeChangeIntentFilter);

    // The actual receiver
    private final BroadcastReceiver timeChangedReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context,Intent intent) {
        final String action = intent.getAction();

        if (action.equals(Intent.ACTION_TIME_CHANGED) ||
            action.equals(Intent.ACTION_TIMEZONE_CHANGED))
        {
            updateWidgets();  // Your code to rebuild the remoteViews or whatever
        }
    }
};

大佬总结

以上是大佬教程为你收集整理的Android通知时间格式如何更新?全部内容,希望文章能够帮你解决Android通知时间格式如何更新?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。