Blank2108 2016-02-18 11:47 采纳率: 0%
浏览 1849

Android TimeZone long[]转换成int[]问题

androidM移植,发现日历崩溃,抓log如下:

 02-17 16:41:29.806  4921  4921 D AndroidRuntime: Shutting down VM
02-17 16:41:29.808  4921  4921 E AndroidRuntime: FATAL EXCEPTION: main
02-17 16:41:29.808  4921  4921 E AndroidRuntime: Process: com.android.calendar, PID: 4921
02-17 16:41:29.808  4921  4921 E AndroidRuntime: java.lang.ClassCastException: long[] cannot be cast to int[]
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.timezonepicker.TimeZoneInfo.getTransitions(TimeZoneInfo.java:202)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.timezonepicker.TimeZoneInfo.<init>(TimeZoneInfo.java:64)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.timezonepicker.TimeZoneData.loadTzsInZoneTab(TimeZoneData.java:446)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.timezonepicker.TimeZoneData.loadTzs(TimeZoneData.java:120)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.timezonepicker.TimeZoneData.<init>(TimeZoneData.java:80)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.timezonepicker.TimeZonePickerView.<init>(TimeZonePickerView.java:66)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.timezonepicker.TimeZonePickerDialog.onCreateView(TimeZonePickerDialog.java:72)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.app.Fragment.performCreateView(Fragment.java:2220)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.app.BackStackRecord.run(BackStackRecord.java:793)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:739)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:95)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:5417)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-17 16:41:29.808  4921  4921 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-17 16:41:29.811  3226  3353 W ActivityManager:   Force finishing activity com.android.calendar/.CalendarSettingsActivity

TimeZoneInfo.java的202附近代码如下:

     private static int[] getTransitions(TimeZone tz, long time)
            throws IllegalAccessException, NoSuchFieldException {
        Class<?> zoneInfoClass = tz.getClass();
        Field mTransitionsField = zoneInfoClass.getDeclaredField("mTransitions");
        mTransitionsField.setAccessible(true);
//此处出错
        int[] objTransitions = (int[])mTransitionsField.get(tz);
        int[] transitions = null;
        if (objTransitions.length != 0) {
            transitions = new int[NUM_OF_TRANSITIONS];
            int numOfTransitions = 0;
            for (int i = 0; i < objTransitions.length; ++i) {
                if (objTransitions[i] < time) {
                    continue;
                }
                transitions[numOfTransitions++] = objTransitions[i];
                if (numOfTransitions == NUM_OF_TRANSITIONS) {
                    break;
                }
            }
        }
        return transitions;
    }

跪求解决

  • 写回答

4条回答 默认 最新

  • Exploring1024 2016-02-18 12:45
    关注

    你移植的什么?系统啊!代码在这环境上怎么会有问题啊

    评论

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境