DatePicker crashes on my device when clicked (with personal app)

前端 未结 7 2008
长发绾君心
长发绾君心 2020-12-12 13:46

Edit : I checked that the issue only appears when the phone is set with \"French\" language.

I\'m currently building my own app and I have an issue

相关标签:
7条回答
  • 2020-12-12 14:43

    It's a Samsung bug in their Lollipop UI implementation. It affects Galaxy S4, S5, Note 3 and probably more devices. For us it occurs on de_DE and de_AT languages, but it appears to be an issue that affects multiple languages.

    I fixed it by forcing Samsung devices to use the Holo theme for the date picker. In our DatePickerFragment:

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        /* calendar code here */
    
        Context context = getActivity();
        if (isBrokenSamsungDevice()) {
            context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light_Dialog);
        }
        return new DatePickerDialog(context, this, year, month, day);
    }
    
    private static boolean isBrokenSamsungDevice() {
        return (Build.MANUFACTURER.equalsIgnoreCase("samsung")
                && isBetweenAndroidVersions(
                Build.VERSION_CODES.LOLLIPOP,
                Build.VERSION_CODES.LOLLIPOP_MR1));
    }
    
    private static boolean isBetweenAndroidVersions(int min, int max) {
        return Build.VERSION.SDK_INT >= min && Build.VERSION.SDK_INT <= max;
    }
    

    Thanks to Samsung, their users will not get the nice material-designed date picker.

    0 讨论(0)
提交回复
热议问题