android - Save Mapview as bitmap -
i trying save mapview bitmap image null pointer exception have checked post here couldnt find solution problem, code under:
public class customview extends mapactivity{ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mapview mapview = new mapview(this, "*************mapapikey****"); mapcontroller mc = mapview.getcontroller(); geopoint p = new geopoint((int) (36 * 1e6),(int) (36 * 1e6)); mc.animateto(p); mc.setzoom(20); mapview.layout(0,0,400,400); bitmap screenshot; mapview.setdrawingcacheenabled(true); screenshot = bitmap.createbitmap(mapview.getdrawingcache()); //this line gives error mapview.setdrawingcacheenabled(false); } //other map functions automatically included here }
what want should able save bitmap on phone , use inanother activity.
error log:
03-03 10:57:01.948: error/androidruntime(8303): java.lang.runtimeexception: unable start activity componentinfo{com.abc.myproject.customview}: java.lang.nullpointerexception 03-03 10:57:01.948: error/androidruntime(8303): @ android.app.activitythread.performlaunchactivity(activitythread.java:2781) 03-03 10:57:01.948: error/androidruntime(8303): @ android.app.activitythread.startactivitynow(activitythread.java:2621) 03-03 10:57:01.948: error/androidruntime(8303): @ android.app.localactivitymanager.movetostate(localactivitymanager.java:127) 03-03 10:57:01.948: error/androidruntime(8303): @ android.app.localactivitymanager.startactivity(localactivitymanager.java:339) 03-03 10:57:01.948: error/androidruntime(8303): @ android.widget.tabhost$intentcontentstrategy.getcontentview(tabhost.java:651) 03-03 10:57:01.948: error/androidruntime(8303): @ android.widget.tabhost.setcurrenttab(tabhost.java:323) 03-03 10:57:01.948: error/androidruntime(8303): @ android.widget.tabhost$2.ontabselectionchanged(tabhost.java:129) 03-03 10:57:01.948: error/androidruntime(8303): @ android.widget.tabwidget$tabclicklistener.onclick(tabwidget.java:453) 03-03 10:57:01.948: error/androidruntime(8303): @ android.view.view.performclick(view.java:2408) 03-03 10:57:01.948: error/androidruntime(8303): @ android.view.view$performclick.run(view.java:8817) 03-03 10:57:01.948: error/androidruntime(8303): @ android.os.handler.handlecallback(handler.java:587) 03-03 10:57:01.948: error/androidruntime(8303): @ android.os.handler.dispatchmessage(handler.java:92) 03-03 10:57:01.948: error/androidruntime(8303): @ android.os.looper.loop(looper.java:143) 03-03 10:57:01.948: error/androidruntime(8303): @ android.app.activitythread.main(activitythread.java:4914) 03-03 10:57:01.948: error/androidruntime(8303): @ java.lang.reflect.method.invokenative(native method) 03-03 10:57:01.948: error/androidruntime(8303): @ java.lang.reflect.method.invoke(method.java:521) 03-03 10:57:01.948: error/androidruntime(8303): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:858) 03-03 10:57:01.948: error/androidruntime(8303): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) 03-03 10:57:01.948: error/androidruntime(8303): @ dalvik.system.nativestart.main(native method) 03-03 10:57:01.948: error/androidruntime(8303): caused by: java.lang.nullpointerexception 03-03 10:57:01.948: error/androidruntime(8303): @ android.graphics.bitmap.createbitmap(bitmap.java:450)
Comments
Post a Comment