Wrox Programmer Forums
|
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 7th, 2011, 09:49 AM
Registered User
 
Join Date: Oct 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 1 Post
Default Ch2 - Linking Activities Using Intents

Hi all,

I have an issue with the Linking Activities Using Intents 'try it out'.

I have created the code and it runs on the emulator, except that I can't close the program down with the Back button. So when I have the Activities screen displayed and I press the Back button nothing happens.

The same behaviour is true of the sample code that I have downloaded.

Does anyone else see this problem and is there a solution?

My emulator is running as Android 2.3.3

Thanks in advance

d404
 
Old October 7th, 2011, 10:11 AM
Registered User
 
Join Date: Oct 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 1 Post
Default

OK I worked it out myself - why do you have to post a question, to them work out what you need to do.

The problem is caused by the onKeyDown() that is stopping normal behaviour working. So in the MainActivity.java file the relevant code should be:
Code:
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    	if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
    		startActivity(new Intent("net.learn2develop.ACTIVITY2"));
    		return false;
    	}
    	return super.onKeyDown(keyCode, event);
Now I can close my app by pressing the back button.
The Following 2 Users Say Thank You to droid404 For This Useful Post:
damac (November 1st, 2011), wel51x (December 26th, 2011)
 
Old December 27th, 2011, 01:30 PM
Authorized User
 
Join Date: Dec 2011
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
Default I'm impressed - how did you figure it out?

'nuff said





Similar Threads
Thread Thread Starter Forum Replies Last Post
Activities Example Attempting to Connect Debugger rman BOOK: Beginning Android Application Development 0 August 22nd, 2011 09:34 AM
ch2 error antorious BOOK: Building PHP Applications with Symfony, CakePHP, and Zend Framework 0 July 14th, 2011 11:24 PM
Chapter 2- Activities nghelam2008 BOOK: Beginning Android Application Development 0 May 26th, 2011 05:58 AM
What can I do with Intents? John_Q_OnStar BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 0 January 21st, 2010 01:56 PM
Chapter-5 on Intents:ContactPickerTester does not show the button "Pick a Contact" sunilm12 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 April 15th, 2009 11:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.