0

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()));
} 
Michael Myers
  • 188,989
  • 46
  • 291
  • 292

1 Answers1

0

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)

Community
  • 1
  • 1
Matthieu
  • 16,103
  • 10
  • 59
  • 86
  • public static final char[] getDateFormatOrder (Context context) Since: API Level 3 Gets the current date format stored as a char array. The array will contain 3 elements (DATE, MONTH, and YEAR) in the order specified by the user's format preference. – jackiezhou Jun 25 '11 at 04:19
  • yes, if you can explain exactly what you are trying to do... you want to modify the lock screen code ? or you want to do something in an app ? – Matthieu Jun 25 '11 at 06:05
  • I want to modify the lock screen. And I want to show the dateformat which I set in setting.Because mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year); private void refreshTimeAndDateDisplay() { mDate.setText(DateFormat.format(mDateFormatString, new Date())); } – jackiezhou Jun 25 '11 at 10:53
  • please see the lockscreen code . http://developer.android.com/reference/android/text/format/DateFormat.html#getDateFormatOrder%28android.content.Context%29 – jackiezhou Jun 25 '11 at 11:10
  • http://android.git.kernel.org/?p=platform/frameworks/policies/base.git;a=blob_plain;f=phone/com/android/internal/policy/impl/LockScreen.java;hb=HEAD – jackiezhou Jun 25 '11 at 11:13