I getting error as null pointer exception
but as per my check, cycle flow is ok.
i get error on this code
bitmap = BitmapFactory.decodeResource(getResources(), MapId.getId(mapName));
mIndiaBitmapLoadedListener.onIndiaBimapLoaded(bitmap);
map.setImageBitmapReset(bitmap, true);
This is my MapId
class
public class MapId
{
public static HashMap<String,Integer> mapids = new HashMap<String, Integer>();
public static void setHashMap()
{
mapids.put("Political Map",R.drawable.indiapoliticalbig);
mapids.put("Physical Map",R.drawable.physicalmap);
mapids.put("Railway Map", R.drawable.railwaymap);
mapids.put("Road Map", R.drawable.roadmap);
mapids.put("Tourist Map", R.drawable.touristmap);
}
public static int getId(String stateName)
{
return mapids.get(stateName);
}
}
This is my Error log
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.compare.IndiaAtlas.MapId.getId(MapId.java:58)
at com.compare.IndiaAtlas.IndiaFragment.onCreateView(IndiaFragment.java:62)
at android.app.Fragment.performCreateView(Fragment.java:2053)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.BackStackRecord.run(BackStackRecord.java:834)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1454)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
we add three new entry in sethashmap()
Railway Map
, Road Map
& Tourist Map
these are get error
but previous entry Physical and Political Map is Running properly.