android - Google maps does not play for some devices and the app crash -
i use code in order instantiate google map :
map = ((mapfragment) getchildfragmentmanager().findfragmentbyid(r.id.map)); mmap = map.getmap(); mmap.setmylocationenabled(true);
this use work fine many devices such nexus 5 , samsung galaxy s6 have tablet (sony xperia z3) , when try navigate fragment app crash logcat:
fatal exception: main process: com.example.veriah.loneworker, pid: 20646 java.lang.nullpointerexception: attempt invoke virtual method 'void com.google.android.gms.maps.googlemap.setmylocationenabled(boolean)' on null object reference
also have activated locations tablet. know why happening?
thank in advance
try solution :
map.getmapasync(new onmapreadycallback() { @override public void onmapready(googlemap googlemap) { mmap = googlemap; googlemap.setmylocationenabled(true); } });
Comments
Post a Comment