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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:24:16+00:00 2026-06-11T18:24:16+00:00

this guy keeps kicking in making my app freeze, any method to fix this

  • 0

this guy keeps kicking in making my app freeze, any method to fix this problem?

here’s my code:

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class StartMoving extends Activity implements OnClickListener {

    Button managemove, returnBack, manageroom, settings, kitchen, addmove;
    ImageButton add1;
    EditText newMove;
    TextView roomName, listMove, roomContent, itemValue;
    CheckBox cbox1;
    Dialog d;
    LinearLayout roomButtons, addRooms;
    RelativeLayout main, merge;
    int check = 0;
    int inc = 1;
    String currentMove = null;
    String currentRoom = null;
    String currentItem = null;
    String currentItemValue = null;
    int itemval = 1;
    boolean notavailroom = true;

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

        roomName = (TextView) findViewById(R.id.tvRoomName);

        managemove = (Button) findViewById(R.id.bManageMove);

        manageroom = (Button) findViewById(R.id.bManageRooms);

        merge = (RelativeLayout) findViewById(R.id.rlmanagemove);

        main = (RelativeLayout) findViewById(R.id.rlmain);

        add1 = (ImageButton) findViewById(R.id.bAddDish);

        roomButtons = (LinearLayout) findViewById(R.id.llButtonRooms);

        kitchen = (Button) findViewById(R.id.bKitchen);

        roomContent = (TextView) findViewById(R.id.tvRoomContent);

        itemValue = (TextView) findViewById(R.id.tvItemValue);

        addRooms = (LinearLayout) findViewById(R.id.llhsvLayout);
        addRooms.setOrientation(LinearLayout.HORIZONTAL);

        managemove.setOnClickListener(this);
        manageroom.setOnClickListener(this);
        add1.setOnClickListener(this);
        kitchen.setOnClickListener(this);

        Intent i = getIntent();     
        currentMove = i.getStringExtra("moveName");

    }

    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.bManageMove:
            merge.setVisibility(View.VISIBLE);
            main.setVisibility(View.INVISIBLE);
            check = 1;
            break;

        case R.id.bManageRooms:
            roomButtons.setVisibility(View.VISIBLE);
            main.setVisibility(View.INVISIBLE);
            //          LinearLayout laddbuttons = (LinearLayout) findViewById(R.id.llhsvLayout);
            //          laddbuttons.setOrientation(LinearLayout.HORIZONTAL);
            //
            //          for (int i = 0; i < 3; i++) {
            //              LinearLayout row = new LinearLayout(this);
            //              row.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            //
            //              for (int j = 0; j < 4; j++) {
            //                  Button btnTag = new Button(this);
            //                  btnTag.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            //                  btnTag.setText("Button " + (j + 1 + (i * 4)));
            //                  btnTag.setId(j + 1 + (i * 4));
            //                  row.addView(btnTag);
            //              }
            //
            //              laddbuttons.addView(row);
            //          }
            check = 2;
            break;

        case R.id.bAddDish:
            currentItem = currentItem + "\nDishwahser";
            currentItemValue = "" + itemval + "\n";
            itemval++;

            roomContent.setText(currentItem);
            itemValue.setText(currentItemValue);
            break;

        case R.id.bKitchen:
            LinearLayout row = new LinearLayout(this);
            row.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

            try {
                SQLHandler kitchen = new SQLHandler(StartMoving.this);
                currentRoom = "Kitchen" + inc;
                kitchen.open();
                String returnedRoom = kitchen.getRoom(currentRoom);

                while (notavailroom) {
                    if (returnedRoom.equals(currentRoom)) {
                        inc++;
                        returnedRoom = kitchen.getRoom(currentRoom);
                    }else{
                        notavailroom = false;
                        kitchen.addRooms(currentMove, currentRoom);
                        roomName.setText(currentRoom);
                        Button b = new Button(StartMoving.this);
                        b.setText(currentRoom);
                        row.addView(b);
                        b.setOnClickListener(new OnClickListener() {

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

                            }
                        });
                        addRooms.addView(row);
                        main.setVisibility(View.VISIBLE);
                        roomButtons.setVisibility(View.INVISIBLE);
                    }
                }
                kitchen.close();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                SQLHandler kitchen = new SQLHandler(StartMoving.this);
                currentRoom = "Kitchen" + inc;
                kitchen.open();
                kitchen.addRooms(currentMove, currentRoom);
                roomName.setText(currentRoom);
                Button b = new Button(StartMoving.this);
                b.setText(currentRoom);
                row.addView(b);
                b.setOnClickListener(new OnClickListener() {

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

                    }
                });
                addRooms.addView(row);
                main.setVisibility(View.VISIBLE);
                roomButtons.setVisibility(View.INVISIBLE);
                kitchen.close();
            }

            break;

        default:
            break;
        }
    }

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

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

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

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

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

        roomName.setText("Hello world");
    }

    public void onBackPressed(){
        super.onBackPressed();

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)  {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            // do something on back.
            if (check == 1) {
                merge.setVisibility(View.INVISIBLE);
                main.setVisibility(View.VISIBLE);
                check = 0;
            }else if (check == 2) {
                main.setVisibility(View.VISIBLE);
                roomButtons.setVisibility(View.INVISIBLE);
                check = 0;
            }else {
                //              this.finish();
                Intent i = new Intent(StartMoving.this, ListMovingNames.class);
                startActivity(i);
            }
            return true;
        }

        return super.onKeyDown(keyCode, event);
    }
}

The culprit for this issue is this line of code

case R.id.bKitchen:
            LinearLayout row = new LinearLayout(this);
            row.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

            try {
                SQLHandler kitchen = new SQLHandler(StartMoving.this);
                currentRoom = "Kitchen" + inc;
                kitchen.open();
                String returnedRoom = kitchen.getRoom(currentRoom);

                while (notavailroom) {
                    if (returnedRoom.equals(currentRoom)) {
                        inc++;
                        returnedRoom = kitchen.getRoom(currentRoom);
                    }else{
                        notavailroom = false;
                        kitchen.addRooms(currentMove, currentRoom);
                        roomName.setText(currentRoom);
                        Button b = new Button(StartMoving.this);
                        b.setText(currentRoom);
                        row.addView(b);
                        b.setOnClickListener(new OnClickListener() {

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

                            }
                        });
                        addRooms.addView(row);
                        main.setVisibility(View.VISIBLE);
                        roomButtons.setVisibility(View.INVISIBLE);
                    }
                }
                kitchen.close();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                SQLHandler kitchen = new SQLHandler(StartMoving.this);
                currentRoom = "Kitchen" + inc;
                kitchen.open();
                kitchen.addRooms(currentMove, currentRoom);
                roomName.setText(currentRoom);
                Button b = new Button(StartMoving.this);
                b.setText(currentRoom);
                row.addView(b);
                b.setOnClickListener(new OnClickListener() {

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

                    }
                });
                addRooms.addView(row);
                main.setVisibility(View.VISIBLE);
                roomButtons.setVisibility(View.INVISIBLE);
                kitchen.close();
            }

            break;

What i basically want to do is when kitchen button is press it first check the database if the text given for the button exist from the database if not then the default name is given to the button and save to the database but if the name does exist another name will be given by incrementing int inc making the name currentRoom = "kitchen " + inc;

here is also the SQLHandler.java for handling the database

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLHandler {
    public static final String KEY_ROOMMOVEHOLDER = "roommoveholder";
    public static final String KEY_ROOM = "room";

    public static final String KEY_ITEMMOVEHOLDER = "itemmoveholder";
    public static final String KEY_ITEMNAME = "itemname";
    public static final String KEY_ITEMVALUE = "itemvalue";
    public static final String KEY_ROOMHOLDER = "roomholder";

    public static final String KEY_MOVENAME = "movename";
    public static final String KEY_ID1 = "_id";
    public static final String KEY_ID2 = "_id";
    public static final String KEY_ID3 = "_id";
    public static final String KEY_ID4 = "_id";
    public static final String KEY_MOVEDATE = "movedate";

    private static final String DATABASE_NAME = "mymovingfriend";
    private static final int DATABASE_VERSION = 1;

    public static final String KEY_TODOMOVE = "todomove";
    public static final String KEY_SORTANDPURGE = "sortandpurge";
    public static final String KEY_RESEARCH = "research";
    public static final String KEY_CREATEMOVINGBINDER = "createmovingbinder";
    public static final String KEY_ORDERSUPPLIES = "ordersupplies";
    public static final String KEY_USEITORLOSEIT = "useitorloseit";
    public static final String KEY_TAKEMEASUREMENTS = "takemeasurements";
    public static final String KEY_CHOOSEMOVER = "choosemover";
    public static final String KEY_BEGINPACKING = "beginpacking";
    public static final String KEY_LABEL = "label";
    public static final String KEY_SEPARATEVALUES = "separatevalues";
    public static final String KEY_DOACHANGEOFADDRESS = "doachangeofaddress";
    public static final String KEY_NOTIFYIMPORTANTPARTIES = "notifyimportantparties";

    private static final String DATABASE_TABLE1 = "movingname";
    private static final String DATABASE_TABLE2 = "movingrooms";
    private static final String DATABASE_TABLE3 = "movingitems";
    private static final String DATABASE_TABLE4 = "todolist";

    public static final String CREATE_TABLE_1 = "CREATE TABLE " + DATABASE_TABLE1 + " (" + 
            KEY_ID1 + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
            KEY_MOVEDATE + " TEXT NOT NULL, " + 
            KEY_MOVENAME + " TEXT NOT NULL);";

    public static final String CREATE_TABLE_2 = "CREATE TABLE " + DATABASE_TABLE2 + " (" + 
            KEY_ID2 + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
            KEY_ROOMMOVEHOLDER + " TEXT NOT NULL, " + 
            KEY_ROOM + " TEXT NOT NULL);";

    public static final String CREATE_TABLE_3 = "CREATE TABLE " + DATABASE_TABLE3 + " (" + 
            KEY_ID3 + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
            KEY_ITEMNAME + " TEXT NOT NULL, " + 
            KEY_ITEMVALUE + " TEXT NOT NULL, " +
            KEY_ROOMHOLDER + " TEXT NOT NULL, " +   
            KEY_ITEMMOVEHOLDER + " TEXT NOT NULL);";

    public static final String CREATE_TABLE_4 = "CREATE TABLE " + DATABASE_TABLE4 + " (" + 
            KEY_ID4 + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
            KEY_TODOMOVE + " TEXT NOT NULL, " +
            KEY_SORTANDPURGE + " TEXT NOT NULL, " + 
            KEY_RESEARCH + " INTEGER NOT NULL, " +
            KEY_CREATEMOVINGBINDER + " TEXT NOT NULL, " + 
            KEY_ORDERSUPPLIES + " TEXT NOT NULL, " +
            KEY_USEITORLOSEIT + " TEXT NOT NULL, " + 
            KEY_TAKEMEASUREMENTS + " TEXT NOT NULL, " +
            KEY_CHOOSEMOVER + " TEXT NOT NULL, " + 
            KEY_BEGINPACKING + " TEXT NOT NULL, " +
            KEY_LABEL + " TEXT NOT NULL, " + 
            KEY_SEPARATEVALUES + " TEXT NOT NULL, " +
            KEY_DOACHANGEOFADDRESS + " TEXT NOT NULL, " + 
            KEY_NOTIFYIMPORTANTPARTIES + " TEXT NOT NULL);";

    private DbHelper ourHelper;
    private final Context ourContext;
    private SQLiteDatabase ourDatabase;

    private static class DbHelper extends SQLiteOpenHelper{

        public DbHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL(CREATE_TABLE_1);
            db.execSQL(CREATE_TABLE_2);
            db.execSQL(CREATE_TABLE_3);
            db.execSQL(CREATE_TABLE_4);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldversion, int newversion) {
            // TODO Auto-generated method stub
            db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE1);
            db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE2);
            db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE3);
            db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE4);
            onCreate(db);
        }
    }

    public SQLHandler(Context c){
        ourContext = c;
    }

    public SQLHandler open() throws SQLException{
        ourHelper = new DbHelper(ourContext);
        ourDatabase = ourHelper.getWritableDatabase();
        return this;
    }

    public void close(){
        ourHelper.close();
    }

    public long createMove(String smovename){
        ContentValues cv = new ContentValues();
        cv.put(KEY_MOVENAME, smovename);
        cv.put(KEY_MOVEDATE, "Not yet set");
        return ourDatabase.insert(DATABASE_TABLE1, null, cv);
    }

    public long addRooms(String sroommoveholder, String sroom){
        ContentValues cv = new ContentValues();
        cv.put(KEY_ROOMMOVEHOLDER, sroommoveholder);
        cv.put(KEY_ROOM, sroom);
        return ourDatabase.insert(DATABASE_TABLE2, null, cv);
    }

    public long addItems(String sitemmoveholder, String sroomholder, String sitemname, String sitemvalue){
        ContentValues cv = new ContentValues();
        cv.put(KEY_ITEMMOVEHOLDER, sitemmoveholder);
        cv.put(KEY_ROOMHOLDER, sroomholder);
        cv.put(KEY_ITEMNAME, sitemname);
        cv.put(KEY_ITEMVALUE, sitemvalue);
        return ourDatabase.insert(DATABASE_TABLE3, null, cv);
    }

    public long todoList(String todoitem){
        ContentValues cv = new ContentValues();
        cv.put(todoitem, "Done");
        return ourDatabase.insert(DATABASE_TABLE4, null, cv);
    }

    public Cursor getMove(){
        String[] columns = new String[]{KEY_ID1, KEY_MOVENAME};
        Cursor cursor = ourDatabase.query(DATABASE_TABLE1, columns, null, null, null, null, null);
        return cursor;
    }

    public String getRoom(String r) throws SQLException{
        String[] columns = new String[]{KEY_ID2, KEY_ROOMMOVEHOLDER, KEY_ROOM};
        Cursor c = ourDatabase.query(DATABASE_TABLE2, columns, KEY_ROOM + "= '" + r + "'" , null, null, null, null);

        if (c != null) {
            c.moveToFirst();
            String roomName = c.getString(2);
            return roomName;
        }
        return null;

    }

}
  • 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-11T18:24:18+00:00Added an answer on June 11, 2026 at 6:24 pm

    Looks to me like this is a constant loop because of this statement:

    if (returnedRoom.equals(currentRoom)) {
        inc++;
        returnedRoom = kitchen.getRoom(currentRoom);
    }
    

    Wouldn’t returnedRoom always equal currentRoom? (simply because currentRoom never changes.)

    Even though you are incrementing inc, it doesn’t change currentRoom.

    I think it should be

    if (returnedRoom.equals(currentRoom)) {
        currentRoom = "Kitchen" + ++inc;
        returnedRoom = kitchen.getRoom(currentRoom);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to achieve what this guy here is doing, only in PHP or
I got this code from our frontend guy for headings: <h2 class=headline><span>Foobar</span></h2> The span
// Original // I want to call this guy -(void)addFavorite:(NSString *)favoriteToAdd at, @selector here
I got a similar problem to this guy while processing 4MB log file. Actually
I'm in the same situation as this guy (only that my problem is with
I have a piece of code where this guy wrote thirty functions for when
I basically have the same question as this guy .. The example in the
In the title view of my view controller, I have this string: @the guy
I'm currently doing this query to find the guy who makes the most calls:
Somewhere some guy said (I honestly do not know where I got this from),

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.