Tuesday, 15 February 2011

android - null pointer exception in eclipse -



android - null pointer exception in eclipse -

normal proximity sensor app,that changes string according value of sensor unless add together if status app crashes launched,after adding if status crashes after using proximity sensor:

java code:

public void onsensorchanged(sensorevent event) { // todo auto-generated method stub if(event.values[0]==3.0) proxtext.settext(string.valueof(event.values[0]));-->line 86 }

logcat:

06-24 02:11:26.185: w/dalvikvm(11580): threadid=1: thread exiting uncaught exception (group=0x41634d40) 06-24 02:11:26.186: e/androidruntime(11580): fatal exception: main 06-24 02:11:26.186: e/androidruntime(11580): process: com.example.tapera, pid: 11580 06-24 02:11:26.186: e/androidruntime(11580): java.lang.nullpointerexception 06-24 02:11:26.186: e/androidruntime(11580): @ com.example.tapera.mainactivity.onsensorchanged(mainactivity.java:86) 06-24 02:11:26.186: e/androidruntime(11580): @ android.hardware.systemsensormanager$sensoreventqueue.dispatchsensorevent(systemsensormanager.java:448) 06-24 02:11:26.186: e/androidruntime(11580): @ android.os.messagequeue.nativepollonce(native method) 06-24 02:11:26.186: e/androidruntime(11580): @ android.os.messagequeue.next(messagequeue.java:138) 06-24 02:11:26.186: e/androidruntime(11580): @ android.os.looper.loop(looper.java:123) 06-24 02:11:26.186: e/androidruntime(11580): @ android.app.activitythread.main(activitythread.java:5102) 06-24 02:11:26.186: e/androidruntime(11580): @ java.lang.reflect.method.invokenative(native method) 06-24 02:11:26.186: e/androidruntime(11580): @ java.lang.reflect.method.invoke(method.java:515) 06-24 02:11:26.186: e/androidruntime(11580): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) 06-24 02:11:26.186: e/androidruntime(11580): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) 06-24 02:11:26.186: e/androidruntime(11580): @ dalvik.system.nativestart.main(native method)

very "event" object in method onsensorchanged in null. thats why exception occurs - there no possibility extract value index "0" in event.values

android nullpointerexception

No comments:

Post a Comment