• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps the application *** has stopped unexpectedly. Please try again

ugur

Lurker
Everytime i am tryin to opnen this button it wont start my source code is here below:

the code it self gives no errors it just wont start when i click on the button


package com.myugur.thebasics;

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,blob ;
float x, y;
Sprite Sprite;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
v = new OurView(this);
v.setOnTouchListener(this);

ball = BitmapFactory.decodeResource(getResources(), R.drawable.ballbig);
blob = BitmapFactory.decodeResource(getResources(), R.drawable.spritesheet);

x= y = 0;
setContentView(v);
}

@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}

@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 isItOK = false;
Sprite Sprite;
boolean SpriteLoaded = false;


public OurView(Context context) {
super(context);
// TODO Auto-generated constructor stub
holder = getHolder();

}

public void run() {
// TODO Auto-generated method stub

while (isItOK == true) {
// Perform canvas drawing
if (!holder.getSurface().isValid()){
continue;

}
if (SpriteLoaded){
Sprite = new Sprite (OurView.this,blob);
SpriteLoaded = true;
}
Canvas c = holder.lockCanvas();
onDraw(c);
holder.unlockCanvasAndPost(c);
}

}

protected void onDraw(Canvas canvas){
canvas.drawARGB(255,150, 150, 10);
canvas.drawBitmap(ball, x- (ball.getWidth()/2), y- (ball.getHeight()/2), null);
Sprite.onDraw(canvas );
}
public void pause() {
isItOK = false;
while (true) {
try {
t.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
break;
}
t = null;
}

public void resume() {
isItOK = true;
t = new Thread(this);
t.start();
}
}

public boolean onTouch(View v, MotionEvent me) {
// TODO Auto-generated method stub

try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

switch (me.getAction()){
case MotionEvent.ACTION_DOWN:
x = me.getX();
y = me.getY();
break;
case MotionEvent.ACTION_UP:
x = me.getX();
y = me.getY();
break;

case MotionEvent.ACTION_MOVE:
x = me.getX();
y = me.getY();
break;
}

return true;
}

}
 
Here is the LogCat u where asking for sorry for not adding it:


03-24 14:41:59.034: D/dalvikvm(337): GC_EXTERNAL_ALLOC freed 49K, 53% free 2553K/5379K, external 1625K/2137K, paused 82ms
03-24 14:42:04.444: D/dalvikvm(337): GC_EXTERNAL_ALLOC freed 8K, 53% free 2571K/5379K, external 2225K/2779K, paused 37ms
03-24 14:42:06.246: W/KeyCharacterMap(337): No keyboard for id 0
03-24 14:42:06.246: W/KeyCharacterMap(337): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-24 14:42:09.255: D/AndroidRuntime(337): Shutting down VM
03-24 14:42:09.255: W/dalvikvm(337): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-24 14:42:09.295: E/AndroidRuntime(337): FATAL EXCEPTION: main
03-24 14:42:09.295: E/AndroidRuntime(337): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.myugur.thebasics.SurfaceViewExample }
03-24 14:42:09.295: E/AndroidRuntime(337): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.app.Activity.startActivityForResult(Activity.java:2827)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.app.Activity.startActivity(Activity.java:2933)
03-24 14:42:09.295: E/AndroidRuntime(337): at com.myugur.thebasics.menu$5.onClick(menu.java:80)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.view.View.performClick(View.java:2485)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.view.View$PerformClick.run(View.java:9080)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.os.Handler.handleCallback(Handler.java:587)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.os.Handler.dispatchMessage(Handler.java:92)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.os.Looper.loop(Looper.java:123)
03-24 14:42:09.295: E/AndroidRuntime(337): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-24 14:42:09.295: E/AndroidRuntime(337): at java.lang.reflect.Method.invokeNative(Native Method)
03-24 14:42:09.295: E/AndroidRuntime(337): at java.lang.reflect.Method.invoke(Method.java:507)
03-24 14:42:09.295: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-24 14:42:09.295: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-24 14:42:09.295: E/AndroidRuntime(337): at dalvik.system.NativeStart.main(Native Method)
 
Back
Top Bottom