Wrox Programmer Forums
|
BOOK: Professional Android 4 Application Development
This is the forum to discuss the Wrox book Professional Android 4 Application Development Reto Meier; ISBN: 978-1-1181-0227-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 4 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 May 10th, 2013, 12:45 AM
Registered User
 
Join Date: Apr 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 7 - Earthquake Part 1

When I try to run this, my preferences activity does not start. This happens whether I run my own app or the one downloaded from Wrox.

I noticed that when I create a new Android Application Project, I have a file <project>/res/menu/main.xml and my main activity has a skeleton onCreateOptionsMenu() function. If I don't delete these - the 'menu' folder and the function skeleton - my projects will not build. Do I need to insert something into this Earthquake Part 1 project to replace what I deleted?
 
Old May 13th, 2013, 06:36 AM
Authorized User
 
Join Date: Jan 2013
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 7 - Earthquake Part 1

Hi oddstray,

The earthquake part 1 code in ch 7 does not make use of any xml file in res/menu, as there isn't such. So i don't understand what you want to do with /menu/main.xml? Build without that should go without errors, what errors do you see?
After clicking menu and then "Preferences" an intent is sent to start preferencesActivity that will show res/layout/preferences.

Good luck!
 
Old May 13th, 2013, 10:18 PM
Registered User
 
Join Date: Apr 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 7 - Earthquake Part 1

I do not see any errors.

What I do with /menu/main.xml is to delete it because it is not used or needed, before I build (my projects will never build unless I delete /menu/main.xml and the onCreateOptionsMenu() override in the main activity class).

When I run the my code for the first part of Chapter 7, or when I run the downloaded book code for the first part of Chapter 7, after clicking the menu and then "Preferences", the res/layout/preferences is not shown. Nothing happens (and there are no additional messages in my Console or in LogCat).
 
Old May 14th, 2013, 05:57 AM
Authorized User
 
Join Date: Jan 2013
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 7 - Earthquake Part 1

This is very odd, oddstray

I just loaded the code on eclipse and found no problems, the only way that PreferencesActivity does not show up is when i don't have
Code:
public boolean onOptionsItemSelected(MenuItem item){
....
}
implemented. Be sure that here the intent is really sent.
 
Old May 17th, 2013, 12:21 AM
Registered User
 
Join Date: Apr 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default D'oh!

Hmmm ... first, when I thought I was running the book code, my Eclipse insisted on running my code. So, it didn't work.

Tonight when I started Eclipse I ran the book code first thing. Then it ran correctly.

And d'oh! What I found was the "onOptionsItemSelected" != "onOptionsItemSelection"


Thanks for helping!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 9 Earthquake Part 3 majeedk BOOK: Professional Android 4 Application Development 0 December 1st, 2012 07:30 AM
Chapter 7 Earthquake 2, Earthquake.java, error onActivityResult dbomberg BOOK: Professional Android 2 Application Development 2 November 30th, 2012 05:52 AM
Earthquake chapter 7 part 2 layingincouch BOOK: Professional Android 4 Application Development 1 October 31st, 2012 05:54 PM
Chapter 7 Part 2 Earthquake Exception clombardo BOOK: Professional Android 2 Application Development 3 April 29th, 2010 10:46 AM
Getting Exception after the Correction -for Chapter 6 Part 2 Earthquake project clombardo BOOK: Professional Android 2 Application Development 1 April 26th, 2010 06:03 AM





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