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 8853613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:41:45+00:00 2026-06-14T13:41:45+00:00

I have an activity which uses a surfaceview as its content view to draw

  • 0

I have an activity which uses a surfaceview as its content view to draw some bitmaps and carry out animations, what is the best way to control starting a new round event to load a new set of bitmaps for the next round within this surfaceview thread or what is the best way to switch from a surfaceview thread, back to the main game activity after a round is done. What I have tried so far, below is a snippet from the surfaceview class where everything is drawn.

              if(isCollided(i)){

            if(imgList.indexOf(imgList.get(i)) == 0){

                    activity.runOnUiThread(new Runnable() {
                        public void run() {
                            Toast.makeText(context, "Correct!", Toast.LENGTH_SHORT).show();
                            Intent i = new Intent(context, AnimeAction.class);
                            context.startActivity(i);
                        }});


            }
  • 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-14T13:41:46+00:00Added an answer on June 14, 2026 at 1:41 pm

    You should not do this :

    MainActivity activity = new MainActivity();
    

    Instead try this :

    MainActivity activity = MainActivity.this;
    

    As far as posting a new set of bitmaps is concerned, I have done it like this in my app :

    public class OurView extends SurfaceView implements Runnable
        {
            Thread t=null;
            SurfaceHolder holder;
            boolean ok;
    
            public OurView(Context context)
            {
                super(context);
                holder=getHolder();
    
            }
            public void run()
            {
                      //draw the bitmaps
                    } 
                public void pause()
            {
                ok=false;
                Log.v("pause()", "ok=false");
                while(true)
                {
                    try{
    
                        t.join();
    
                    }
                    catch(InterruptedException e)
                    {
                        Log.v("pause()",e.toString());
                    }
    
                    break;
                }
               t=null;
    
            }
            public void resume()
            {
                ok=true;
                if(t==null)
                {
                 t=new Thread(this);
                   t.start();
                   Log.v("resume()", "new thread started");
                }
                else
                {
                    Log.v("resume()", "new thread not started as t!=null");
                }
            }
    }
    

    And in the Activity’s onResume() and onCreate() :

    @Override
        protected void onPause() {
            // TODO Auto-generated method stub
            super.onPause();
            Log.v("onPause()", "super.onPause()");
            v.pause();  //V IS AN OBJECT OF THE CLASS OurView
    
        }
        @Override
        protected void onResume() {
            // TODO Auto-generated method stub
            super.onResume();
            Log.v("onResume()", "super.onResume()");
            v.resume();
          }
    

    I learnt it from this video (and the subsequent one’s 1.28 -1.33) – http://youtube.com/watch?v=Z2YogvILjvo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity (activity1) which uses a decently large amount of bitmaps. I
I have an activity which uses two Loaders. Each of them returns different type
I have an Activity which uses a Fragment . I simply want to pass
I have an Android app which includes an activity called Help This uses a
I have an activity which shows some List entries. When I click on a
I have an activity with a listView, which uses a custom row layout defined
I have implemented one application in android which uses epublib to view .epub files.
I have an activity in Android which uses a ListView. When I click on
I need some help here. Basically, I have an Activity. This uses the startActivityForResult()
I have an Activity which starts an AsyncTask. This AsyncTask uses AutoCompleteTextView.showDropDown() in onPostExecute.

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.