1

im using Google Maps inside a Fragment. It works well and everythings fine. But when i'm leaving the map fragment, it's getting very strange!

I'm also using json.io lib to parse JSON from / to Server. After closing the map fragment i get the following error from json.io:

java.io.IOException: Class listed in @type [com.myapp.constructors.GeoConstructor] is not found, pos = 43

The App works fine until i open and close the map fragment. If i insert call of maps.MapFragment to any other Activity / Fragment, the strange error also happens!

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/map"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  class="com.google.android.gms.maps.SupportMapFragment"/>

So the error must be the call of the Fragment. I also tried inflating the MapFragment programmatically:

mMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);

if (mMapFragment == null) {
        mMapFragment = SupportMapFragment.newInstance();

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(android.R.id.content, mMapFragment, MAP_FRAGMENT_TAG);
        fragmentTransaction.commit();
    }

But this won't solve the error.

Propably the use of Google's MapFragment / SupportMapFragment manipulates something inside my app. What could cause this behaviour?

Hope u can help me.

Got it:

Seems that the ClassLoader changed after inflating the Map. Don't know why, but after manually calling

Thread.currentThread().setContextClassLoader(BaseActivity.cLoader);

after closing the map fragment, error disappers. Hope it helps :)

Community
  • 1
  • 1
Farasy
  • 304
  • 2
  • 8
  • 1
    the error looks like its coming from your app not json, is the parsing still happening when you try to close the fragment? – tyczj Jan 09 '14 at 20:31
  • Thank for your answer tyczj. It's still parsing in some cases, but in most cases the mentioned error appears. And it means primitive types, cause the constructors doen't usw any custom objects. Very strange... – Farasy Jan 09 '14 at 20:45
  • so what ever that is probably got garbage connected when you exited the fragment – tyczj Jan 09 '14 at 20:47
  • But it must be called by GMaps!?! The error appears even if i only add the MapFragment to XML in any Activity / Fragment. – Farasy Jan 09 '14 at 20:50

0 Answers0