首页 \ 问答 \ 从背景返回后,Skobbler Map崩溃(Skobbler Map crashes after returning from background)

从背景返回后,Skobbler Map崩溃(Skobbler Map crashes after returning from background)

我正在开发一个应用程序,我正在使用skobbler sdk 2.4,当我打开Map时遇到问题,然后我转到后台并打开一个需要大量内存的应用程序,如Clash of Clans:P。

几秒钟后,当我返回到包含地图的活动时,它会变黑并在2秒后将此错误提供给logcat:

A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x44 in tid 27000 (GLThread 72284)

我对sdk附带的示例尝试了同样的事情,起初它崩溃了,因为它无法找到保存在应用程序实例中的String路径。 我已针对此问题制定了解决方法,并修复了来自应用程序类DemoApplication的null异常崩溃。 这不是问题。 问题出在地图上。

在此之后,我走到了同一点,即使使用示例应用程序,我也遇到了同样的问题。 地图崩溃,并且在活动处于后台后它无法再次初始化。

任何建议表示赞赏:)


I am developing an application where I am using skobbler sdk 2.4 and I have encountered a problem when I open Map and then I go to background and open an app that needs a lot of memory like Clash of Clans :P.

After a few seconds when I return to the activity that contains the map it goes black and after 2 seconds it give this error to logcat:

A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x44 in tid 27000 (GLThread 72284)

I have tried the same thing with the example that comes with the sdk and at first it crashes because it cant find String path that is kept inside application instance. I have made a workaround for this problem and fixed the null exception crash coming from application class DemoApplication. This wasnt a problem. The problem is with the map.

After this I went at the same point, I had the same problem even with the example app. The maps crashes and it cant initialize itself again after activity has been in background.

Any suggestion is appreciated :)

更新时间:2023-03-22 20:03

最满意答案

感谢SylviA,当我检查我的示例应用程序时,我试图修复Null Pointer Exception的问题并通过电子邮件发送。

当我第二次编写代码时,我意识到我做错了,这就是这次荒谬崩溃的原因。

MapActivity.class初始化map时,我在代码中发布了一个部分。 这些更改是在DemoUtils.class

/**
 * Initializes the SKMaps framework
 */
public static void initializeLibrary(final Context context) {
    final DemoApplication app = (DemoApplication)context.getApplicationContext();
    // get object holding map initialization settings
    SKMapsInitSettings initMapSettings = new SKMapsInitSettings();
    // set path to map resources and initial map style

    SharedPreferences mSharedPreferences = context.getSharedPreferences("map",0);
    if(app.getMapResourcesDirPath()==null) { // here happens the first error
        Toast.makeText(context,"Null Exception Error avoided", Toast.LENGTH_SHORT).show();
        app.setMapResourcesDirPath(mSharedPreferences.getString("map_path",null));
    }else {
        SharedPreferences.Editor mEditor = mSharedPreferences.edit();
        mEditor.putString("map_path",app.getMapResourcesDirPath());
        mEditor.commit();
    }

    initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle(app.getMapResourcesDirPath() + "daystyle/", "daystyle.json"));

我做错了就是在这一行,它是这样的:

initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle( null + "daystyle/", "daystyle.json"));

它必须这样做:

initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle( app.getMapResourcesDirPath() + "daystyle/", "daystyle.json"));

谢谢你的时间 :)


Thanks to SylviA while I was checking my sample app I was trying to fix the problem of Null Pointer Exception and send it via email.

While I was writing the code for the second time I realized that I was doing something wrong and that was the reason of this absurd crash.

Here I am posting a part from the code where I have made my changes when map is initialized in MapActivity.class. These changes are made inside DemoUtils.class

/**
 * Initializes the SKMaps framework
 */
public static void initializeLibrary(final Context context) {
    final DemoApplication app = (DemoApplication)context.getApplicationContext();
    // get object holding map initialization settings
    SKMapsInitSettings initMapSettings = new SKMapsInitSettings();
    // set path to map resources and initial map style

    SharedPreferences mSharedPreferences = context.getSharedPreferences("map",0);
    if(app.getMapResourcesDirPath()==null) { // here happens the first error
        Toast.makeText(context,"Null Exception Error avoided", Toast.LENGTH_SHORT).show();
        app.setMapResourcesDirPath(mSharedPreferences.getString("map_path",null));
    }else {
        SharedPreferences.Editor mEditor = mSharedPreferences.edit();
        mEditor.putString("map_path",app.getMapResourcesDirPath());
        mEditor.commit();
    }

    initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle(app.getMapResourcesDirPath() + "daystyle/", "daystyle.json"));

What I was doing wrong was at this line, and it was something like this:

initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle( null + "daystyle/", "daystyle.json"));

And it has to be done like this:

initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle( app.getMapResourcesDirPath() + "daystyle/", "daystyle.json"));

Thanks for your time :)

相关问答

更多
  • 目前,您无法自行完成此操作。 中间步骤是将您的数据转换为.osm(我们的地图转换工具可以理解),然后我们可以创建.skm文件。 注意:目前,允许将自定义.osm文件转换为.skm的工具不公开(取决于您的项目规模,我们可能能够根据企业协议进行转换 - 发送电子邮件至dev@skobbler.com )。 Currently you cannot do this on your own. An intermediary step would be to convert your data to .osm (so ...
  • 遗憾的是,SKAnnotations没有集群支持(您必须自己实现选择哪个注释在每个缩放级别可见的逻辑)。 注意:对SKAnnotations的群集支持正在进行中 SKPoiCluster将与SKMapPoi一起使用。 (SKMapPoi提供群集支持)SKMapPoi的权衡是可以使用的图标相当有限 - 来自png文件的精灵,所以如果你想修改一个图标,你需要修改png文件。 Unfortunately there is no clustering support for SKAnnotations (you w ...
  • 目前SDK不允许下载动态边界框的地图,但只允许下载预先映射的地图。 我们无法按需创建Northwich地图,但知道需要这样的地图,我们可以提前为Northwich创建地图并将其添加到我们的maps.xml文件中,以便在需要时下载。 Right now the SDK does not allow downloading maps for dynamic bounding boxes but only priorly predefined map cuts. E.e. we cannot create on ...
  • 此时SDK不支持此功能。 At this point the SDK does not support this functionality.
  • 根据Ando对原始问题的评论并参考此处的文档,我更新了代码以使用他描述的解决方法,允许注释显示到缩放级别2。 原始代码: SKAnnotation annotation = new SKAnnotation(i++); annotation.getLocation().setLongitude(result.longitude); annotation.getLocation().setLatitude(result.latitude); annotation.setMininumZoomLevel(1); ...
  • 感谢SylviA,当我检查我的示例应用程序时,我试图修复Null Pointer Exception的问题并通过电子邮件发送。 当我第二次编写代码时,我意识到我做错了,这就是这次荒谬崩溃的原因。 在MapActivity.class初始化map时,我在代码中发布了一个部分。 这些更改是在DemoUtils.class /** * Initializes the SKMaps framework */ public static void initializeLibrary(final Context c ...
  • 我在创建地图时错过了self.map.delegate = self这一行。 I have just missed the line self.map.delegate = self when I create my map.
  • by using following code i can draw map. Untitled Document