Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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!
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.