android - 将值从一个 Activity 检索到另一个 Activity 时导致应用程序崩溃

标签 android cordova google-maps

我正在为 map 创建一个 Activity ,另一个是为插件创建 Activity ,我希望从插件中获取经纬度和经度以在 map 上添加标记位置,但它会崩溃。

这是插件 Activity

 this.callbackContext = callbackContext;
    context=this;

    Intent intent = new Intent(this.cordova.getActivity(),MapsActivity.class);
    intent.putExtra("lat", "23.074");
    intent.putExtra("lon", "47.230");

    this.cordova.getActivity().startActivity(intent);

    if (this.cordova != null) {
        this.cordova.startActivityForResult(this, intent,101);
        return true;
    }
     return false;

这是 map Activity

  //drawing marker
    double pointOneLat = Double.parseDouble(getIntent().getExtras().getString("lat"));
    double pointOneLang = Double.parseDouble(getIntent().getExtras().getString("lon"));


    pointOne = new LatLng(pointOneLat, pointOneLang);

    mMap.addMarker(new MarkerOptions().position(pointOne).title("Point 1"));

//

谢谢....

最佳答案

可能是您正在尝试调用直接 map Activity,而 lat 和 lon 没有进入您的 Activity ,因此它为 null 并且您的 Activity 崩溃。首先调用插件并将该参数传递给 Activity

关于android - 将值从一个 Activity 检索到另一个 Activity 时导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39165996/

相关文章:

Android — 像 Google Chrome 新按钮一样单击按钮时添加新标签?

java - 如何在首选项中正确将 URI 保存到文件

android - 哪个fb ://url is suitable to trigger the FB application prompting to share content?

cordova - 如何查看 Phonegap/Cordova 项目中安装的所有插件?

来自 URL 的 Android google mapv2 图标

android - 拥有 godaddy 的网络主机,但用户端有 Squarespace 运行

java - 如何在phonegap android中隐藏地址栏

javascript - 谷歌地图 V3 : Hexagon grid - Error with setWindow

android map 在恢复 fragment 后停止响应

Android MenuItem setActionView(空)崩溃