java - Force Closes on Opening Activity -
i working on app touch screen , basketball moves there. there except force closes when open mini-app list of activities start. after scanning through several times not find anything.
this java class , after logcat:
package com.frostbytedev.addsub; import android.app.activity; import android.content.context; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.canvas; import android.os.bundle; import android.view.motionevent; import android.view.surfaceholder; import android.view.surfaceview; import android.view.view; import android.view.view.ontouchlistener; public class surfaceviewexample extends activity implements ontouchlistener { ourview v; bitmap ball; float x = 0; float y = 0; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); v = new ourview(this); setcontentview(v); v.setontouchlistener(this); ball = bitmapfactory.decoderesource(getresources(), r.drawable.bball); } @override protected void onpause() { // todo auto-generated method stub super.onpause(); v.pause(); } @override protected void onresume() { // todo auto-generated method stub super.onresume(); v.resume(); } public class ourview extends surfaceview implements runnable { thread t = null; surfaceholder holder; boolean isitokay = false; public ourview(context context) { super(context); // todo auto-generated constructor stub holder = getholder(); } @override public void run() { // todo auto-generated method stub while(isitokay) { if(!holder.getsurface().isvalid()){ continue; } canvas c = holder.lockcanvas(); c.drawargb(255, 150, 150, 150); c.drawbitmap(ball, x-(ball.getwidth()/2), y-(ball.getheight()/2), null); holder.unlockcanvasandpost(c); } } public void pause(){ isitokay = false; while(true){ try{ t.join(); } catch(interruptedexception e){ e.printstacktrace(); } } } public void resume() { isitokay = true; t = new thread(this); t.start(); } } @override public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub x = event.getx(); y = event.gety(); return false; } }
logcat:
05-09 19:24:35.730: d/libegl(8218): loaded /system/lib/egl/libegl_adreno200.so 05-09 19:24:35.740: d/libegl(8218): loaded /system/lib/egl/libglesv1_cm_adreno200.so 05-09 19:24:35.750: d/libegl(8218): loaded /system/lib/egl/libglesv2_adreno200.so 05-09 19:24:35.800: d/openglrenderer(8218): enabling debug mode 0 05-09 19:24:44.658: d/androidruntime(8218): shutting down vm 05-09 19:24:44.658: w/dalvikvm(8218): threadid=1: thread exiting uncaught exception (group=0x40a7a930) 05-09 19:24:44.668: e/androidruntime(8218): fatal exception: main 05-09 19:24:44.668: e/androidruntime(8218): java.lang.arrayindexoutofboundsexception: length=5; index=5 05-09 19:24:44.668: e/androidruntime(8218): @ com.frostbytedev.addsub.menu.onlistitemclick(menu.java:25) 05-09 19:24:44.668: e/androidruntime(8218): @ android.app.listactivity$2.onitemclick(listactivity.java:319) 05-09 19:24:44.668: e/androidruntime(8218): @ android.widget.adapterview.performitemclick(adapterview.java:298) 05-09 19:24:44.668: e/androidruntime(8218): @ android.widget.abslistview.performitemclick(abslistview.java:1102) 05-09 19:24:44.668: e/androidruntime(8218): @ android.widget.abslistview$performclick.run(abslistview.java:2751) 05-09 19:24:44.668: e/androidruntime(8218): @ android.widget.abslistview$1.run(abslistview.java:3426) 05-09 19:24:44.668: e/androidruntime(8218): @ android.os.handler.handlecallback(handler.java:725) 05-09 19:24:44.668: e/androidruntime(8218): @ android.os.handler.dispatchmessage(handler.java:92) 05-09 19:24:44.668: e/androidruntime(8218): @ android.os.looper.loop(looper.java:137) 05-09 19:24:44.668: e/androidruntime(8218): @ android.app.activitythread.main(activitythread.java:5237) 05-09 19:24:44.668: e/androidruntime(8218): @ java.lang.reflect.method.invokenative(native method) 05-09 19:24:44.668: e/androidruntime(8218): @ java.lang.reflect.method.invoke(method.java:511) 05-09 19:24:44.668: e/androidruntime(8218): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:799) 05-09 19:24:44.668: e/androidruntime(8218): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:566) 05-09 19:24:44.668: e/androidruntime(8218): @ dalvik.system.nativestart.main(native method)
Comments
Post a Comment