Android: Using back button to main activity gives error forced close?

I found the answer by using the code below. I had to put that code before the onCreate the errors I've been having was putting that code after the onCreate. It seems to work for me unless anyone else got better suggestions.

Even though both code works, I prefer the first one as it would kill the current activity 'finish()' and return to the previous screen and the second code it will start the activity and keep both activity in the stack Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent. KEYCODE_BACK) { Pop("Back Button"); Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); return true; } return super. OnKeyDown(keyCode, event); } or Override public boolean onKeyDown(int keyCode, KeyEvent event) { //replaces the default 'Back' button action if(keyCode==KeyEvent.

KEYCODE_BACK) { //do whatever you want the 'Back' button to do //as an example the 'Back' button is set to start a new Activity named 'NewActivity' this. StartActivity(new Intent(thisActivity. This,nextActivity.

Class)); } return true; }.

I found the answer by using the code below. I had to put that code before the onCreate the errors I've been having was putting that code after the onCreate. It seems to work for me unless anyone else got better suggestions.

Even though both code works, I prefer the first one as it would kill the current activity 'finish()' and return to the previous screen and the second code it will start the activity and keep both activity in the stack. @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent. KEYCODE_BACK) { Pop("Back Button"); Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); return true; } return super.

OnKeyDown(keyCode, event); } or @Override public boolean onKeyDown(int keyCode, KeyEvent event) { //replaces the default 'Back' button action if(keyCode==KeyEvent. KEYCODE_BACK) { //do whatever you want the 'Back' button to do //as an example the 'Back' button is set to start a new Activity named 'NewActivity' this. StartActivity(new Intent(thisActivity.

This,nextActivity. Class)); } return true; }.

New CustomerListItem("Start Trip", StartTripActivity. New CustomerListItem("Clock in", ClockinActivity. New CustomerListItem("Customer Svc", CustomerSvcActivity.

New CustomerListItem("Independent Inspection", InspectionActivity. New CustomerListItem("Pick Up", PickUpActivity. New CustomerListItem("Log Out", LogoutActivity.

Selection = (TextView) findViewById(R.id. TextView txtCurrentTime= (TextView)findViewById(R.id. Button btn = (Button) findViewById(R.id.

Code = (EditText)findViewById(R.id. BtnLogout = (Button) findViewById(R.id. BtnCancel = (Button) findViewById(R.id.

LblResult = (TextView)findViewById(R.id. Intent I = new Intent(getApplicationContext(), Login.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions