java - Weird App not working on different mobile -


i develop google map related app on samsung mobile , release in play store shows approx 7000 supported devices. when downloaded app on samsung mobile it's working fine not working on moto , sony mobiles.

when try debug moto mobile it's shows "shutting down vm"

06-20 00:17:25.276      457-457/com.mycompany.mypackage d/androidruntime﹕ shutting down vm 06-20 00:17:25.281      457-457/com.mycompany.mypackage e/androidruntime﹕ fatal exception: main process: com.mycompany.mypackage, pid: 457 java.lang.runtimeexception: unable instantiate activity componentinfo{com.mycompany.mypackage/com.mycompany.mypackage.mapsactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.string android.content.context.getpackagename()' on null object reference         @ android.app.activitythread.performlaunchactivity(activitythread.java:2225)         @ android.app.activitythread.handlelaunchactivity(activitythread.java:2388)         @ android.app.activitythread.access$800(activitythread.java:148)         @ android.app.activitythread$h.handlemessage(activitythread.java:1292)         @ android.os.handler.dispatchmessage(handler.java:102)         @ android.os.looper.loop(looper.java:135)         @ android.app.activitythread.main(activitythread.java:5312)         @ java.lang.reflect.method.invoke(native method)         @ java.lang.reflect.method.invoke(method.java:372)         @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:901)         @ com.android.internal.os.zygoteinit.main(zygoteinit.java:696)  caused by: java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.string android.content.context.getpackagename()' on null object reference         @ android.content.contextwrapper.getpackagename(contextwrapper.java:131)         @ android.location.geocoderparams.<init>(geocoderparams.java:50)         @ android.location.geocoder.<init>(geocoder.java:83)         @ com.mycompany.mypackage.mapsactivity.<init>(mapsactivity.java:96)         @ java.lang.reflect.constructor.newinstance(native method)         @ java.lang.class.newinstance(class.java:1572)         @ android.app.instrumentation.newactivity(instrumentation.java:1088)         @ android.app.activitythread.performlaunchactivity(activitythread.java:2215) 

            

answer: above weird problem,

i encounter weird problem discuss above figure out due geocoder. solution of above problem simple shown below

geocoder gc = new geocoder(this, locale.getdefault());

public class mapsactivity extends fragmentactivity implements .... { ............... geocoder gc = new geocoder(this, locale.getdefault()); @override protected void oncreate(bundle savedinstancestate) { ............       } ............ } 

in above code snippet geocoder defined globally. doesn't work on different devices. works on samsung devices. solution figure out works on devices (tested on samsung, moto, sony).

public class mapsactivity extends fragmentactivity implements .... { ............... @override protected void oncreate(bundle savedinstancestate) { ............       } public void send(view view) {     try {         geocoder gc = new geocoder(this, locale.getdefault());         list<address> list = gc.getfromlocationname(message, 1); .........}     } ............ } 

in above code snippet geocoder defined locally inside function.

this solution works me. hope in future encounter same problem may solution helps.

thanks


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -