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 January 11th, 2012, 06:31 PM
Registered User
 
Join Date: Jan 2012
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Default Chapter 2 Linking Activities with Intents

I've got an error on this line of code:

startActivity(new Intent(net.learn2develop.ACTIVITY2));

stating "net.learn2develop.ACTIVITY2 cannot be resolved to a type"

I've compared my code against the book over and over and am not finding mistakes.

I've got this in the manifest:

Code:
<activity 
            android:name=".Activity2"
            android:label="Activity 2">
            <intent-filter> 
                <action android:name="net.learn2develop.ACTIVITY2" />
                <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
The suggestions to fix it in Eclipse are to create the class ACTIVITY2... but the book had me create the class as Activity2... then Eclipse suggests the code:

public class ACTIVITY2 extends Intent

but the book called for

public class Activity2 extends Activity


Any help is appreciated.
 
Old January 11th, 2012, 06:46 PM
Registered User
 
Join Date: Jan 2012
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Well I read forward and found the bit about how you can use different code to call an intent within the same application so changed the line to:

startActivity(new Intent(this, Activity2.class));

and everything works now. Still not sure why the original code wasn't ok, as it was calling it by the name in the manifest. Oh well, on we go

Last edited by Gink; January 11th, 2012 at 07:00 PM..
 
Old January 11th, 2012, 08:21 PM
Authorized User
 
Join Date: Nov 2011
Posts: 86
Thanks: 3
Thanked 5 Times in 5 Posts
Default

Hi Gink
For what is worth, I has some of the same problems. I don't remember what I did to fix it. The code in my version is the same as yours. I can not see any errors.
Cliff
__________________
"Software to the Stars"
Failure is not an option. It comes bundled with your Microsoft products.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch2 - Linking Activities Using Intents droid404 BOOK: Beginning Android Application Development 2 December 27th, 2011 01:30 PM
Chapter 2 - <Intents> program BrianMcK BOOK: Beginning Android Application Development 1 October 21st, 2011 09:31 AM
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.