Skobbler card crashes after returning from background

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

After a few seconds when I go back to the activity containing the map it will turn black and after 2 seconds it will give this logcat error:

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

      

I tried the same with the example that comes with the sdk and at first it fails because it cannot find the String path that is stored inside the application instance. I did a workaround for this problem and fixed the NULL exception coming from the application class DemoApplication

. It's not a problem. Card problem.

After that I went to the same point, I had the same problem even with the sample application. Cards crash and cannot initialize themselves again after the activity has been in the background.

Any suggestion is appreciated :)

+3


source to share


1 answer


Thanks to SylviA, when I was checking my sample app, I was trying to fix the Null Pointer Exception issue and email it.

While I was writing the code a second time, I realized that I was doing something wrong and that was the cause of this absurd failure.

Here I am posting the part from the code where I made my changes when the map is initialized to MapActivity.class

. These changes are made insideDemoUtils.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 on this line and it was something like this:



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

      

And it should be done like this:

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

      

Thank you for your time:)

+2


source







All Articles