Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8280663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:45:35+00:00 2026-06-08T09:45:35+00:00

OK so I’m using xml to set this menu which is supported by the

  • 0

OK so I’m using xml to set this menu which is supported by the following java code

package starting.rt;

import java.util.List;
import java.util.Random;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Menu extends Activity implements OnClickListener{

    View.OnTouchListener gestureListener;

    TextView display;
    Button begin;
    Button random;
    Button game;

    TextView counter;

    Button next;
    Button previous;
    Button moreapps;
    Button rate;

    Random myRandom;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(starting.rt.R.layout.menu);

        begin = (Button) findViewById(starting.rt.R.id.Begin);
        random = (Button) findViewById(starting.rt.R.id.Random);
        display = (TextView) findViewById(starting.rt.R.id.tvResults);
        counter = (TextView) findViewById(starting.rt.R.id.tvCounter);
        next = (Button) findViewById(starting.rt.R.id.Next);
        previous = (Button) findViewById(starting.rt.R.id.Previous);
        moreapps = (Button)findViewById(R.id.More);
        rate = (Button) findViewById(R.id.rate);
        game = (Button) findViewById(R.id.game);

//       display.setOnTouchListener(this.gestureListener);



begin.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {

        Intent openStartingPoint = new Intent("starting.rt.RelationshipTipsActivity");
        startActivity(openStartingPoint);

    }});

moreapps.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


    Intent goToMarket; 
    goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:\"Wompa\"")); 
    startActivity(goToMarket); 
    }});

game.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


    Intent openStartingPoint = new Intent("starting.rt.GameView");
    startActivity(openStartingPoint);
    }});


    rate.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("market://details?id=" + getPackageName()));
            startActivity(i);
        }});}

    public void onClick(View v) {
        // TODO Auto-generated method stub

    }

}

Now what’s supposed to be happening is when they click on the game which starts a new java class called GameView it crashes on clicked. Every other button works.

This is the code from GameView

package starting.rt;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class GameView extends SurfaceView {
       private GameLoopThread gameLoopThread;
       private List<Sprite> sprites = new ArrayList<Sprite>();
       private List<TempSprite> temps = new ArrayList<TempSprite>();
       private long lastClick;
       private Bitmap bmpBlood;




       public GameView(Context context) {
             super(context);
             gameLoopThread = new GameLoopThread(this);
             getHolder().addCallback(new SurfaceHolder.Callback() {

                    public void surfaceDestroyed(SurfaceHolder holder) {
                           boolean retry = true;
                           gameLoopThread.setRunning(false);
                           while (retry) {
                                  try {
                                        gameLoopThread.join();
                                        retry = false;
                                  } catch (InterruptedException e) {}
                           }
                    }


                    public void surfaceCreated(SurfaceHolder holder) {
                           createSprites();
                           gameLoopThread.setRunning(true);
                           gameLoopThread.start();
                    }


                    public void surfaceChanged(SurfaceHolder holder, int format,
                                  int width, int height) {
                    }
             });
             bmpBlood = BitmapFactory.decodeResource(getResources(), R.drawable.blood1);
       }

       private void createSprites() {
             sprites.add(createSprite(R.drawable.bad1));
//             sprites.add(createSprite(R.drawable.bad2));
//             sprites.add(createSprite(R.drawable.bad3));
//             sprites.add(createSprite(R.drawable.bad4));
//             sprites.add(createSprite(R.drawable.bad5));
//             sprites.add(createSprite(R.drawable.bad6));
//             sprites.add(createSprite(R.drawable.good1));
//             sprites.add(createSprite(R.drawable.good2));
//             sprites.add(createSprite(R.drawable.good3));
//             sprites.add(createSprite(R.drawable.good4));
//             sprites.add(createSprite(R.drawable.good5));
//             sprites.add(createSprite(R.drawable.good6));
       }

       private Sprite createSprite(int resouce) {
             Bitmap bmp = BitmapFactory.decodeResource(getResources(), resouce);
             return new Sprite(this, bmp);
       }

       @Override
       protected void onDraw(Canvas canvas) {
             canvas.drawColor(Color.BLACK);
             for (int i = temps.size() - 1; i >= 0; i--) {
                    temps.get(i).onDraw(canvas);
             }
             for (Sprite sprite : sprites) {
                    sprite.onDraw(canvas);
             }
       }

       @Override
       public boolean onTouchEvent(MotionEvent event) {
             if (System.currentTimeMillis() - lastClick > 300) {
                    lastClick = System.currentTimeMillis();
                    float x = event.getX();
                    float y = event.getY();
                    synchronized (getHolder()) {
                           for (int i = sprites.size() - 1; i >= 0; i--) {
                                  Sprite sprite = sprites.get(i);
                                  if (sprite.isCollition(x, y)) {
                                        sprites.remove(sprite);
                                        temps.add(new TempSprite(temps, this, x, y, bmpBlood));
                                        break;
                                  }
                           }
                    }
             }
             return true;
       }
}

The GameView calls a few other classes for things part of the game but it crashes before it can start. I think it’s crashing because it’s switching from xml layout to the java surfaceview. Help would be appreciated 🙂 Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:45:37+00:00Added an answer on June 8, 2026 at 9:45 am

    First of all, you should always post in your questions the stacktrace with the exception from the Logcat if your app crashes.

    You can’t start a SurfaceView directly, instead your custom SurfaceView must be embedded in an Activity like any other view in android. For example:

    public class GameViewActivity extends Activity {
    
         @Override
         public void onCreate(Bundle savedInstance) {
              super.onCreate(savedInstance);
              setContentView(new GameView(this));
         }   
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.