Codenameone- NavigateToLocation崩溃错误

时间:2018-10-18 05:01:39

标签: android codenameone

我从Google Play的崩溃报告中看到以下错误日志。我不知道是什么触发了此问题。我正在使用TrackLocation API和Google Maps NavigatetoLocation方法来使用本机映射功能。我找不到与App相关的问题,并且App崩溃了。如果有人遇到类似问题,请告诉我。谢谢

错误日志:

java.lang.RuntimeException: 
      at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2955)
      at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3030)
      at android.app.ActivityThread.-wrap11 (Unknown Source)
      at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1696)
      at android.os.Handler.dispatchMessage (Handler.java:105)
      at android.os.Looper.loop (Looper.java:164)
      at android.app.ActivityThread.main (ActivityThread.java:6938)
      at java.lang.reflect.Method.invoke (Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)


    Caused by: java.lang.NullPointerException: 
      at com.codename1.social.GoogleImpl.onCreate (GoogleImpl.java:375)
      at com.codename1.impl.android.AndroidNativeUtil.onCreate (AndroidNativeUtil.java:84)
      at com.codename1.impl.android.CodenameOneActivity.onCreate (CodenameOneActivity.java:307)
      at com.xxxx.xxx.MainStub.onCreate (MainStub.java:53)
      at android.app.Activity.performCreate (Activity.java:7183)
      at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1220)
      at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2908)

代码:

  public static boolean navigateToLocation(String location) {
            boolean flg = false;
            String url = "comgooglemaps://?q=" + Util.encodeUrl("");
            if (location != null) {
                url = "comgooglemaps://?q=" + Util.encodeUrl(location.replace(',', ' ')) + "&directionsmode=driving&zoom=16&views=traffic";
            }

            Boolean b = Display.getInstance().canExecute(url);
            if (b != null && b.booleanValue()) {
                Command googleMaps = new Command("Use Google Maps");
                Command appleMaps = new Command("Use Apple Maps");
                Command cancel = new Command("Cancel");
                ComponentGroup cmps = ComponentGroup.enclose(
                        new Button(appleMaps), new Button(googleMaps)
                );
                // allows us to resize the dialog properly
                final boolean[] reshow = new boolean[1];
                Dialog dlg = new Dialog(BoxLayout.y()) {
                    @Override
                    protected void sizeChanged(int w, int h) {
                        reshow[0] = true;
                        dispose();
                    }
                };
                dlg.setDialogUIID("Container");
                dlg.add(cmps).add(ComponentGroup.enclose(new Button(cancel)));
                Command result = dlg.showStretched(BorderLayout.SOUTH, true);
                if (result == googleMaps) {
                    if (reshow[0]) {
                        navigateToLocation(location);
                        return false;
                    }
                    Display.getInstance().execute(url);
                    flg = true;
                } else if (result == appleMaps) {
                    if (reshow[0]) {
                        navigateToLocation(location);
                        return false;
                    }
                    if (location == null) {
                        Location l = LocationManager.getLocationManager().getLastKnownLocation();
                        Display.getInstance().openNativeNavigationApp(l.getLatitude(), l.getLongitude());
                    } else {
                        Display.getInstance().openNativeNavigationApp(location.replace(',', ' '));
                    }
                    flg = true;
                }
            } else if (location == null) {
                Location l = LocationManager.getLocationManager().getLastKnownLocation();
                Display.getInstance().openNativeNavigationApp(l.getLatitude(), l.getLongitude());
            } else {
                Display.getInstance().openNativeNavigationApp(location.replace(',', ' '));
            }
            return flg;
        }

0 个答案:

没有答案