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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:38:47+00:00 2026-06-11T13:38:47+00:00

I am trying to display a dialog box in the hello Android Sudoku example

  • 0

I am trying to display a dialog box in the hello Android Sudoku example but when I run the app nothing happens. In the game.java I check if the puzzle is solved like this

/******Check to see if the game is complete**/
   public boolean isSolved()
   {
       for (int element : puzzle) {
           if (element == 0) return false;
        }
        return true;           
   }

Then in the PuzzleView in the onKeyDown method i try to detect if isSolved is true and if it is display the dialog

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (game.isSolved() == true) {
        Intent i = new Intent(mActivity, Congratulations.class);
        getContext().startActivity(i);
    } else {
        Log.d(TAG, "onKeyDown: keycode=" + keyCode + ", event=" + event);
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            select(selX, selY - 1);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            select(selX, selY + 1);
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            select(selX - 1, selY);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            select(selX + 1, selY);
            break;
        case KeyEvent.KEYCODE_0:
        case KeyEvent.KEYCODE_SPACE:
            setSelectedTile(0);
            break;
        case KeyEvent.KEYCODE_1:
            setSelectedTile(1);
            break;
        case KeyEvent.KEYCODE_2:
            setSelectedTile(2);
            break;
        case KeyEvent.KEYCODE_3:
            setSelectedTile(3);
            break;
        case KeyEvent.KEYCODE_4:
            setSelectedTile(4);
            break;
        case KeyEvent.KEYCODE_5:
            setSelectedTile(5);
            break;
        case KeyEvent.KEYCODE_6:
            setSelectedTile(6);
            break;
        case KeyEvent.KEYCODE_7:
            setSelectedTile(7);
            break;
        case KeyEvent.KEYCODE_8:
            setSelectedTile(8);
            break;
        case KeyEvent.KEYCODE_9:
            setSelectedTile(9);
            break;
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            game.showKeypadOrError(selX, selY);
            break;
        default:
            return super.onKeyDown(keyCode, event);
        }
        return false;
    }
    return false;

}

I am learning java and Android development so please any help as to where I am going wrong will be much appreciated. If anyone needs more information please just ask and I will put it in an edit section for the question.

  • 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-11T13:38:48+00:00Added an answer on June 11, 2026 at 1:38 pm

    In the end the way I checked to see if the game was complete was to have this in the game.class

    /****** Check to see if the game is complete **/
    public boolean isSolved() {
        for (int element : puzzle) {
            if (element == 0)
                return false;
        }
        return true;
    }
    

    And also

    public boolean checkIsSolved()
    {
        //check if the game is complete after each valid move
        if (isSolved() == true) { 
            Intent i = new Intent(this, Congratulations.class); 
            startActivity(i);} 
            else
            {
                return false;
            }
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make my form display a dialog box (possibly via Javascript)
I am trying to display a progress dialog in java 'A'. At the moment
I am trying to display a modal Javascript dialog box in Chrome when a
I'm trying to display a modal box with another page inside, but I just
I am trying to display a custom dialog box multiple times using the following
I'm trying to create a Dialog box that will display a video (quick tutorial)
I am new to JQuery and trying to display a Yes/No confirmation dialog box
I am trying to display a Dialog with an EditText field, pre-populate the EditText
I'm trying to display a modal dialog with a spinning icon to indicate something
I'm trying to display an inline dialog (that is, aui-inline-dialog, not aui-dialog) in my

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.