Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
This is the forum to discuss the Wrox book Professional Android Application Development by Reto Meier; ISBN: 9780470344712
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 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 30th, 2009, 06:09 PM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
Default Chapter 6 Sample Earthquake 2

Hello,

I get the following error when I click on a specific earthquake from the list of quakes: "The application com.paad.earthquake (process com.paad.earthquake) has stopped unexpectedly. Please try again."

The Logs show the following:

Code:
01-30 17:01:02.452: WARN/WindowManager(52): Attempted to add window with non-application token WindowToken{4345d4f8 token=null}.  Aborting.
01-30 17:01:02.462: DEBUG/AndroidRuntime(204): Shutting down VM
01-30 17:01:02.462: WARN/dalvikvm(204): threadid=3: thread exiting with uncaught exception (group=0x40010e28)
01-30 17:01:02.471: ERROR/AndroidRuntime(204): Uncaught handler: thread main exiting due to uncaught exception
01-30 17:01:02.502: ERROR/AndroidRuntime(204): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.view.ViewRoot.setView(ViewRoot.java:388)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:90)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.app.Dialog.show(Dialog.java:212)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.app.Activity.showDialog(Activity.java:2279)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at com.paad.earthquake.Earthquake$1.onItemClick(Earthquake.java:72)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.widget.AdapterView.performItemClick(AdapterView.java:283)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.widget.ListView.performItemClick(ListView.java:3049)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:1415)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.os.Handler.handleCallback(Handler.java:542)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.os.Handler.dispatchMessage(Handler.java:86)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.os.Looper.loop(Looper.java:123)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at android.app.ActivityThread.main(ActivityThread.java:3742)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at java.lang.reflect.Method.invokeNative(Native Method)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at java.lang.reflect.Method.invoke(Method.java:515)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
01-30 17:01:02.502: ERROR/AndroidRuntime(204):     at dalvik.system.NativeStart.main(Native Method)
I am using the latest version of the sample code. Any reasons why?

Thanks!
 
Old January 31st, 2009, 12:28 PM
Reto's Avatar
Wrox Author
Points: 287, Level: 5
Points: 287, Level: 5 Points: 287, Level: 5 Points: 287, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2008
Location: London, United Kingdom
Posts: 61
Thanks: 1
Thanked 7 Times in 6 Posts
Default

Quote:
Originally Posted by sunrain View Post
I am using the latest version of the sample code. Any reasons why?
It looks like a got a bit carried away with a couple of find-replace searches right before I uploaded the sample code. What's happened is I've used getApplicationContext() when I should be passing in the Activity's context.

What you need to do is fix these two lines, replacing getApplicationContext() with this, as shown below:

Code:
LayoutInflater li = LayoutInflater.from(getApplicationContext());
View quakeDetailsView = li.inflate(R.layout.quake_details, null);
    
AlertDialog.Builder quakeDialog = new AlertDialog.Builder(getApplicationContext());
Becomes:
Code:
LayoutInflater li = LayoutInflater.from(this);
View quakeDetailsView = li.inflate(R.layout.quake_details, null);
    
AlertDialog.Builder quakeDialog = new AlertDialog.Builder(this);
Sorry about that, I've got a few updates to the sample code pending that should be available in the next few days.
__________________
Reto Meier

Author, "Professional Android 4 Application Development", Wrox, ©2012, 2010, 2008
@retomeier
 
Old January 31st, 2009, 04:06 PM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks, that did the trick!




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 - Web Services Sample mjk12345 BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 2 July 8th, 2008 01:53 PM
Chapter 10 Sample Code jramkawsky BOOK: Professional Java Development with the Spring Framework 0 December 3rd, 2005 08:44 AM





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