本文介绍了三星S4 OS 4.3时间选择器对话框崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到这个问题时,我点击Timepicker。此问题不发生任何其它设备,以下是错误日志:

 错误日志:
    显示java.lang.NullPointerException
    在android.widget.TimePicker.updateInputState(TimePicker.java:846)
    在android.widget.TimePicker.onSaveInstanceState(TimePicker.java:561)
    在android.view.View.dispatchSaveInstanceState(View.java:13117)
    在android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2822)
    在android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    在android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    在android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    在android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    在android.view.View.saveHierarchyState(View.java:13100)
    在com.android.internal.policy.impl.PhoneWindow.saveHierarchyState(PhoneWindow.java:1930)
    在android.app.Dialog.onSaveInstanceState(Dialog.java:407)
    在android.app.TimePickerDialog.onSaveInstanceState(TimePickerDialog.java:216)
    在android.app.Activity.saveManagedDialogs(Activity.java:1269)
    在android.app.Activity.performSaveInstanceState(Activity.java:1187)
    在android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1240)
    在android.app.ActivityThread.performStopActivityInner(ActivityThread.java:330​​9)
    在android.app.ActivityThread.handleStopActivity(ActivityThread.java:3369)
    在android.app.ActivityThread.access $ 1000(ActivityThread.java:159)
    在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1338)
    在android.os.Handler.dispatchMessage(Handler.java:99)
    在android.os.Looper.loop(Looper.java:137)
    在android.app.ActivityThread.main(ActivityThread.java:5419)
    在java.lang.reflect.Method.invokeNative(本机方法)
    在java.lang.reflect.Method.invoke(Method.java:525)
    在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1187)
    在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
    在dalvik.system.NativeStart.main(本机方法)


解决方案

要触发TimePicker ::>

  INT小时,分钟;
TimePickerDialog mTimePicker =新TimePickerDialog(mContext,
    新TimePickerDialog.OnTimeSetListener(){
  @覆盖
  公共无效onTimeSet(TimePicker timePicker,诠释selectedHour,诠释selectedMinute){
小时= selectedHour;
    分钟= selectedMinute;
 }
},小时,分钟,FALSE); //是24小时时间
mTimePicker.setTitle(选择时间);
小时= c.get(Calendar.HOUR);
分钟= c.get(Calendar.MINUTE);
mTimePicker.updateTime(小时,分钟);
mTimePicker.show();

I keep on getting this issue whenever I click on Timepicker. This issue is not occurring on any other devices, Following is the error log:

Error log:
    java.lang.NullPointerException
    at android.widget.TimePicker.updateInputState(TimePicker.java:846)
    at android.widget.TimePicker.onSaveInstanceState(TimePicker.java:561)
    at android.view.View.dispatchSaveInstanceState(View.java:13117)
    at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2822)
    at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2828)
    at android.view.View.saveHierarchyState(View.java:13100)
    at com.android.internal.policy.impl.PhoneWindow.saveHierarchyState(PhoneWindow.java:1930)
    at android.app.Dialog.onSaveInstanceState(Dialog.java:407)
    at android.app.TimePickerDialog.onSaveInstanceState(TimePickerDialog.java:216)
    at android.app.Activity.saveManagedDialogs(Activity.java:1269)
    at android.app.Activity.performSaveInstanceState(Activity.java:1187)
    at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1240)
    at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3309)
    at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3369)
    at android.app.ActivityThread.access$1000(ActivityThread.java:159)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1338)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5419)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
    at dalvik.system.NativeStart.main(Native Method)
解决方案

Add this where you want to Trigger TimePicker::>

int hour,minute;
TimePickerDialog mTimePicker = new TimePickerDialog(mContext, 
    new TimePickerDialog.OnTimeSetListener() {
  @Override
  public void onTimeSet(TimePicker timePicker,int selectedHour, int selectedMinute) {
hour = selectedHour;
    minute = selectedMinute;
 }


}, hour, minute, false);// Yes 24 hour time
mTimePicker.setTitle("Select Time");
hour = c.get(Calendar.HOUR);
minute = c.get(Calendar.MINUTE);
mTimePicker.updateTime(hour, minute);
mTimePicker.show();

这篇关于三星S4 OS 4.3时间选择器对话框崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 18:41