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 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
 
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
 
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
 
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
 
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.





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





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