大佬教程收集整理的这篇文章主要介绍了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,请注明来意。