Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DatePicker crash in samsung with android 5.0

Tags:

I am having trouble with creating a datepicker in samsung note 2 device with lollipop 5.0. The exception is:

java.util.IllegalFormatConversionException: %d can not format java.lang.String arguments     at java.util.Formatter.badArgumentType(Formatter.java:1489)     at java.util.Formatter.transformFromInteger(Formatter.java:1689)     at java.util.Formatter.transform(Formatter.java:1461)     at java.util.Formatter.doFormat(Formatter.java:1081)     at java.util.Formatter.format(Formatter.java:1042)     at java.util.Formatter.format(Formatter.java:1011)     at java.lang.String.format(String.java:1803)     at android.content.res.Resources.getString(Resources.java:1457)     at android.content.Context.getString(Context.java:397)     at android.widget.SimpleMonthView$MonthViewTouchHelper.getItemDescription(SimpleMonthView.java:684)     at android.widget.SimpleMonthView$MonthViewTouchHelper.onPopulateNodeForVirtualView(SimpleMonthView.java:628)     at com.android.internal.widget.ExploreByTouchHelper.createNodeForChild(ExploreByTouchHelper.java:377)     at com.android.internal.widget.ExploreByTouchHelper.createNode(ExploreByTouchHelper.java:316)     at com.android.internal.widget.ExploreByTouchHelper.access$100(ExploreByTouchHelper.java:50)     at com.android.internal.widget.ExploreByTouchHelper$ExploreByTouchNodeProvider.createAccessibilityNodeInfo(ExploreByTouchHelper.java:711)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfVirtualNode(AccessibilityInteractionController.java:1179)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1091)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:1087)     at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:888)     at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:155)     at android.view.AccessibilityInteractionController.access$400(AccessibilityInteractionController.java:53)     at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:1236)     at android.os.Handler.dispatchMessage(Handler.java:102)     at android.os.Looper.loop(Looper.java:145)     at android.app.ActivityThread.main(ActivityThread.java:5944)     at java.lang.reflect.Method.invoke(Native Method)     at java.lang.reflect.Method.invoke(Method.java:372)     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184) 

I have used the example provided in the official android studio page:

public static class DatePickerFragment extends DialogFragment             implements DatePickerDialog.OnDateSetListener {      @Override     public Dialog onCreateDialog(Bundle savedInstanceState) {         // Use the current date as the default date in the picker         final Calendar c = Calendar.getInstance();         int year = c.get(Calendar.YEAR);         int month = c.get(Calendar.MONTH);         int day = c.get(Calendar.DAY_OF_MONTH);         // Create a new instance of DatePickerDialog and return it          DatePickerDialog dpd = new DatePickerDialog(getActivity(), this,year, month, day);         return dpd;       }     @Override     public void onDateSet(DatePicker view, int year, int month, int day) {         // get the date here      } } 

I call it like this:

DialogFragment newFragment = new DatePickerFragment(); newFragment.show(getFragmentManager(), "datePicker"); 

In other devices works fine.

I also tried creating my own layout with a DatePicker in it, really simple but also crashes. Is this some Android bug?

like image 651
Vilson Hoxhallari Avatar asked Feb 05 '15 13:02

Vilson Hoxhallari


People also ask

Is DatePicker dialog class available in Android?

Android App Development for Beginners Android Date Picker allows you to select the date consisting of day, month and year in your custom user interface. For this functionality android provides DatePicker and DatePickerDialog components.

What is DatePicker and TimePicker in Android?

Android DatePicker is a widget to select date. It allows you to select date by day, month and year. Like DatePicker, android also provides TimePicker to select time. The android.

What is the use of DatePicker view in Android?

Android provides controls for the user to pick a time or pick a date as ready-to-use dialogs. Each picker provides controls for selecting each part of the time (hour, minute, AM/PM) or date (month, day, year).


1 Answers

As Ridcully says, its an issue with Samsung's 5.0 implementation

Workaround suggestions can be found here. Unfortunately none are the most pretty.

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

like image 66
kassim Avatar answered Nov 16 '22 17:11

kassim