Here map api Android: MapRoute Out of memory error on zoomTo() -


i seem getting out of memory error on older devices when attempt add maproute object map. happens in routes outside of city size , long routes across us. have attempted on emulator device (nexus 4.4.4) , physical device (samsung galaxy prevail 4.4.4). here code calculating route:

public void calculateroute(geocoordinate start, geocoordinate end, final routelistener listener) {         routeplan routeplan = new routeplan();         routeoptions routeoptions = new routeoptions();         routeoptions.settransportmode(routeoptions.transportmode.car);         routeoptions.setroutetype(routeoptions.type.shortest);         routeoptions.setroutecount(1);         routeplan.setrouteoptions(routeoptions);          routemanager routemanager = new routemanager();         routeplan.addwaypoint(start);         routeplan.addwaypoint(end);          routemanager.calculateroute(routeplan, new routemanager.listener() {             @override             public void oncalculateroutefinished(routemanager.error error, list<routeresult> list) {                 if(error == routemanager.error.none) {                     if(list.get(0).getroute() != null) {                         maproute maproute = new maproute(list.get(0).getroute());                         listener.gotroute(maproute);                     } else {                         listener.gotroute(null);                     }                 } else {                     listener.gotroute(null);                 }             }             @override             public void onprogress(int i) {}         });      } 

and here result of callback in fragment:

        placeservices placeservices = new placeservices(getactivity());                 placeservices.calculateroute(pickupmarker.getcoordinate(), dropoffmarker.getcoordinate(),                         new placeservices.routelistener() {                             @override                             public void gotroute(maproute maproute) {                                 if(maproute != null) {                                      map.addmapobject(maproute);                                     geoboundingbox gbb = maproute.getroute().getboundingbox(); // here oom                                     map.zoomto(gbb, map.animation.none, map.move_preserve_orientation);                                 }                             }                         }); 

anyone run issue? not affecting newer devices, have tested on nexus 6 no problems.

stack trace:

error in converting images     java.lang.outofmemoryerror         @ android.graphics.bitmapfactory.nativedecodestream(native method)         @ android.graphics.bitmapfactory.decodestreaminternal(bitmapfactory.java:620)         @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:596)         @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:634)         @ com.here.android.mpa.internal.x.a(diskcache.java:447)         @ com.here.android.mpa.internal.x$b.a(diskcache.java:399)         @ com.here.android.mpa.internal.x$b.doinbackground(diskcache.java:381)         @ android.os.asynctask$2.call(asynctask.java:288)         @ java.util.concurrent.futuretask.run(futuretask.java:237)         @ android.os.asynctask$serialexecutor$1.run(asynctask.java:231)         @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112)         @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587)         @ java.lang.thread.run(thread.java:841) 

update: took me minute narrow down since issue sporadic, error occurs @ zoomto, not adding object map. i've updated title , comments.

i ended calling zoomto() method before calculated route fixed issue, guess it's not try add route object , zoom @ same time:

// zoom markers before route calculated avoid oom on devices.         if(pickupcoordinate != null && dropoffcoordinate != null) {             geoboundingbox geoboundingbox;             geoboundingbox = util.calculateboundingbox(pickupcoordinate, dropoffcoordinate);             map.zoomto(geoboundingbox, map.animation.linear, map.move_preserve_orientation);         }          placeservices placeservices = new placeservices(getactivity());         placeservices.calculateroute(pickupmarker.getcoordinate(), dropoffmarker.getcoordinate(),                 new placeservices.routelistener() {                     @override                     public void gotroute(maproute maproute) {                         if(maproute != null) {                             map.addmapobject(maproute);                             }                     }                 }); 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -