in Education by
I have an activity A that launches B with an Intent. (B is a MapActivity and has some async code) in B i have the following code @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if ((keyCode == KeyEvent.KEYCODE_BACK)) { // Log.d(this.getClass().getName(), "back button pressed"); finish(); return true; } return super.onKeyDown(keyCode, event); } This simply not work. I mean that when I press the back button on the phone, the current activity B disappears and the activity A that launched B is shown. If I press again on A the button that launch B, I see B is exactly how it was when I closed it. SAME text in textboxes, same Map position... So i think the activity B is not really closed. How can I close it for real so when I launch again it, activity B is cleas as new born? EDIT: just to make the question clearer: I want it to work like this: when the user is on activity B and BACK button is pressed, B has to be closed and destroyed. When the user again launches B from A, B has to be launched as a NEW activity, with blank field, reset map, etc., etc., ... just like the first time the user launches B from A. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Instead of returning true, try returning super.onKeyDown(keyCode, event) after finish(). You can try 1 more thing: specify android:noHistory="true" in the manifest for that activity. Specifying this attribute doesn't keep the activity on the Activity Stack. http://developer.android.com/guide/topics/manifest/activity-element.html#nohist

Related questions

0 votes
    I'm designing a service that will comprise a cloud-based database (with a UI for us to manage the data), ... sit behind mobile apps. Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I am creating an application for Android. I am using Realm as a Database. Realm working fine in the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I'm looking at making an custom Android object Serializable. Should be simple I just cannot find a easy ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I've made a fresh eclipse reinstall + Android SDK v4.0. I am trying to create a new 4.0 AVD ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I'm trying to execute the following command: arp -a and I would like to redirect the output to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I've noticed on Marshmallow (e.g. Nexus 6P) and also on some more recently updated Lollipop phones ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I'm trying to execute the following command: arp -a and I would like to redirect the output to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    i have this problem that i want to upload image on a server through multi-part form but its keep ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I want making multi-bluetooth from Android studio. I found multi-bluetooth java code libraries. but I am ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    i want to run a task every 5 minutes. i've tried to solve it with an IntentService and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    i have this problem that i want to upload image on a server through multi-part form but its keep ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    I want to put a settings icon to the right of a full-width button which when clicked opens an ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Animation example link: https://drive.google.com/open?id=1M5UBylFj0_8mtOEQT7jjsPN9DcCjyfPI I want to show my app ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I just updated to Android Studio 3.4 (Canary 5). Then I opened my existing project (which worked ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    How To Escape String Like Below. I Use Below Code But Say "The method unescape(String) is undefined ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
...