我已经能够在Android模拟器1.5,1.6,2.0和2.1中重现以下行为:从任何EditText
视图复制文本“241299999999999999”;转到任何日期选择器(例如:日期和时间设置)并将该值粘贴为年份或月份。
使用DatePicker
的应用程序与以下堆栈跟踪崩溃:
10-24 15:50:54.674: E/AndroidRuntime(1012): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(1012): java.lang.NumberFormatException: unable to parse '241299999999999999' as integer
at java.lang.Integer.parse(Integer.java:390)
at java.lang.Integer.parseInt(Integer.java:374)
at java.lang.Integer.parseInt(Integer.java:333)
at com.android.internal.widget.NumberPicker.getSelectedPos(NumberPicker.java:379)
at com.android.internal.widget.NumberPicker.access$1100(NumberPicker.java:37)
at com.android.internal.widget.NumberPicker$NumberRangeKeyListener.filter(NumberPicker.java:362)
at com.android.internal.widget.NumberPicker$NumberPickerInputFilter.filter(NumberPicker.java:316)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:417)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:409)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:28)
at android.widget.TextView.onTextContextMenuItem(TextView.java:6932)
at android.widget.TextView$MenuHandler.onMenuItemClick(TextView.java:6853)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:133)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:813)
at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:120)
at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:884)
at android.widget.AdapterView.performItemClick(AdapterView.java:283)
at android.widget.ListView.performItemClick(ListView.java:3132)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:1620)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3948)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
at dalvik.system.NativeStart.main(Native Method)
这是一个已知的错误吗?
答案 0 :(得分:2)
假设整数需要4个字节,它可以采用的最大值是
2 ^ 32 = 4,294,967,296。
您已经给出了超出范围的值,以便将其识别为整数。
答案 1 :(得分:0)
对我来说不会发生;在我的三星Fascinate(2.2)上,它甚至不允许我粘贴或输入一个那么大的数字。