Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning Android Application Development
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 April 28th, 2011, 10:33 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 2:Dialog project "force close" error

Hi, i am a 25 year software engineer-retired. i wrote most of my code in the 80s-90s...fortran, pascal, basic, and macro-32. now i am learning java with the eclipse ide for android os.

After getting several "The application DialogActivity has stopped unexpectedly. Please try again." with a "force close" option, i downloaded and executed the source code from your web site. i get the same results when i click the "Click to display a dialog box."

any ideas?
thanks
Reply With Quote
  #2 (permalink)  
Old April 29th, 2011, 12:54 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default additional information

forgot to say that the downloaded code was programmed to show a progress dialog and it worked fine. i modified the showDialog(1) to be like the display a dialog activity showDialog(0) and it then fails.

ichthus
Reply With Quote
  #3 (permalink)  
Old May 11th, 2011, 07:15 AM
Registered User
 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just to say that I am getting the same error. Any help would be appreciated.

Martin
Reply With Quote
  #4 (permalink)  
Old May 16th, 2011, 10:35 AM
Registered User
 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fix, and explanation

Ah, it's crashing there because when you change it to showDialog(0) , right after it returns the AlertDialog, it's trying to call _progressDialog which hasn't been initialized yet (because that gets initialized in case 1 of onCreateDialog).

Some simple ducttape:

In the initial variable declarations, right after
Code:
    private Handler _progressHandler;
Shove in:
Code:
    //DUCTTAPE
    private boolean inProgressMode = false;
For the onCreate():
Code:
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button btn = (Button) findViewById(R.id.btn_dialog);        
        btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDialog(0);
                //DUCTTAPE Conditional
                if (inProgressMode) {
                    _progress = 0;
                    _progressDialog.setProgress(0);
                    _progressHandler.sendEmptyMessage(0);
                } //End the DUCTTAPE
            }
        });
And then in onCreateDialog, right after "case 1:", put
Code:
    inProgressMode = true; //DUCTTAPE Trigger
Reply With Quote
  #5 (permalink)  
Old May 16th, 2011, 11:16 AM
Registered User
 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Better tape

Bah, while my previous ducttape does work, it's inefficient.

Thus, rather than mess with all that, this makes a better fix:
Code:
                //DUCTTAPE Conditional
                if (_progressDialog != null) {
                    _progress = 0;
                    _progressDialog.setProgress(0);
                    _progressHandler.sendEmptyMessage(0);
                } //End the DUCTTAPE
No sense in making a new variable when there's already one to be used.
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 15. "Sign Up for new account" gets error: 26 - Error Locating Server/Instance Tanya Roslyakova BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 March 8th, 2011 10:34 AM
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
Chapter 18: Getting "Failed to generate a user instance of SQL Server" error HungryCaterpillar BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 November 11th, 2009 01:56 PM
Need code corrections "get sub or function not defined" error" bluesboytoo Excel VBA 1 October 22nd, 2009 11:12 PM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM



All times are GMT -4. The time now is 09:20 PM.


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