为什么我无法在锁屏中获取 Settings.System.DATE_FORMAT?
这是android中锁屏的一些代码。 日期格式是:
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
我设置:
mDateFormatString =Settings.System.getString(getContext().getContentResolver(), Settings.System.DATE_FORMAT) ;
为什么我无法在LockScreen中获取Settings.System.DATE_FORMAT?
private void resetStatusInfo(KeyguardUpdateMonitor updateMonitor) {
mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo();
mPluggedIn = updateMonitor.isDevicePluggedIn();
mBatteryLevel = updateMonitor.getBatteryLevel();
/* for dual sim, by jing.wang */
mStatus[SimCardID.ID_ZERO.toInt()] = getCurrentStatus(updateMonitor.getSimState());
if (isDualMode) {
mStatus[SimCardID.ID_ONE.toInt()] = getCurrentStatus(updateMonitor.getSimState (SimCardID.ID_ONE));
updateLayout(mStatus[SimCardID.ID_ZERO.toInt()], SimCardID.ID_ZERO, mStatus[SimCardID.ID_ONE.toInt()]);
updateLayout(mStatus[SimCardID.ID_ONE.toInt()], SimCardID.ID_ONE, mStatus[SimCardID.ID_ZERO.toInt()]);
} else {
updateLayout(mStatus[SimCardID.ID_ZERO.toInt()]);
}
refreshBatteryStringAndIcon();
refreshAlarmDisplay();
mTimeFormat = DateFormat.getTimeFormat(getContext());
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
refreshTimeAndDateDisplay();
updateStatusLines();
}
编辑:我想修改锁屏代码。我想显示我在设置中设置的日期格式。但现在我设置日期格式“dd-MM-yyyy”,它无法在锁定屏幕中显示。日期以mDateFormatString的格式显示。
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
这是refreshTimeAndDateDisplay的代码。
private void refreshTimeAndDateDisplay() {
mDate.setText(DateFormat.format(mDateFormatString, new Date()));
}
This is some Code of the LockScreen in android.
The dateformat is:
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
And I set:
mDateFormatString =Settings.System.getString(getContext().getContentResolver(), Settings.System.DATE_FORMAT) ;
Why I can't get Settings.System.DATE_FORMAT in the LockScreen?
private void resetStatusInfo(KeyguardUpdateMonitor updateMonitor) {
mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo();
mPluggedIn = updateMonitor.isDevicePluggedIn();
mBatteryLevel = updateMonitor.getBatteryLevel();
/* for dual sim, by jing.wang */
mStatus[SimCardID.ID_ZERO.toInt()] = getCurrentStatus(updateMonitor.getSimState());
if (isDualMode) {
mStatus[SimCardID.ID_ONE.toInt()] = getCurrentStatus(updateMonitor.getSimState (SimCardID.ID_ONE));
updateLayout(mStatus[SimCardID.ID_ZERO.toInt()], SimCardID.ID_ZERO, mStatus[SimCardID.ID_ONE.toInt()]);
updateLayout(mStatus[SimCardID.ID_ONE.toInt()], SimCardID.ID_ONE, mStatus[SimCardID.ID_ZERO.toInt()]);
} else {
updateLayout(mStatus[SimCardID.ID_ZERO.toInt()]);
}
refreshBatteryStringAndIcon();
refreshAlarmDisplay();
mTimeFormat = DateFormat.getTimeFormat(getContext());
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
refreshTimeAndDateDisplay();
updateStatusLines();
}
Edit: I want to modify the lock screen code. And I want to display the dateformat which I set in setting. But now I set the dateformat "dd-MM-yyyy", it can't display in the lock screen. The date display by the format of mDateFormatString.
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
This is the code of refreshTimeAndDateDisplay.
private void refreshTimeAndDateDisplay() {
mDate.setText(DateFormat.format(mDateFormatString, new Date()));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能应该看看这个: 如何使用设置中默认设置的日期格式? (getDateFormatOrder 为您提供用户的格式设置)
You should probably look at this : How to use the date format that has been setup as default in Settings? (getDateFormatOrder gives you the user's format setting)