"Finish" Activity from Dialog... Not finishing

by shemazar » Tue, 14 Jul 2009 02:50:00 GMT

Sponsored Links

I've got an application with one main activity, and I've got an error
dialog with a "ok" button on it, that when pressed calls "finish" on
the activity.  It seems to work fine when I test the app manually, but
when I run the "monkey" tool, it is somehow killing my dialog by
pressing 'Ok', but not finishing the app.

All my dialogs are managed by the activity, and here's my dialog

                case ERROR_DIALOG_ID:
                    Log.d("ErrorDialog", "Error Shown.");
                    errorDialogShown = true;
                        final Activity instance = this;
                        return new AlertDialog.Builder(this)
                                .setPositiveButton(getText(R.string.ok), new
DialogInterface.OnClickListener() {
                           public void onClick(DialogInterface dialog, int id) {
                                    Log.d("ErrorDialog", "OK clicked.");
                                    Log.d("ErrorDialog", "Finished.");

And here's my log output:

I/ActivityManager(  572): Starting activity: Intent
{ action=android.intent.action.MAIN categories=
{android.intent.category.LAUNCHER} flags=0x10000000 comp={XXX} }
D/onCreateDialog(  841): Showing progress dialog.
D/GpsLocationProvider(  572): setMinTime 0
W/KeyCharacterMap(  841): No keyboard for id 0
W/KeyCharacterMap(  841): Using default keymap: /system/usr/keychars/
D/progressDialog(  841): Try last loc clicked.
D/LocationManager(  841): removeUpdates: listener = x...@43753f58
D/ErrorDialog(  841): Error Shown.
I/ActivityManager(  572): Displayed activity XXX: 4993 ms
D/ErrorDialog(  841): OK clicked.
D/ErrorDialog(  841): Finished.
W/IInputConnectionWrapper(  678): showStatusIcon on inactive
I/AndroidRuntime(  876): AndroidRuntime onExit calling exit(0)
D/dalvikvm(  678): GC freed 1453 objects / 41216 bytes in 117ms

And the activity never dies--in other words, it's remaining visible to
the user.  It's like the dialog was dismissed, and that was it.  When
I hit the back button on the device, it'll destroy the instance.

Any ideas on what I'm doing wrong?



Other Threads

1. HTC Hero (Sense UI) in emulator

Is there a way to get HTC Hero system image for the emulator?

Sense UI has quite some changes to activities like Contacts. So
intents to select Phone number (new Intent(Intent.ACTION_PICK,
Phones.CONTENT_URI) ) work differently from default Contacts app, and
things like viewing Call Log ( new Intent
("com.android.phone.action.RECENT_CALLS"); ) do not work at all.
Is there a way to test my code against Hero device, beside getting
physical device.



2. Using Pre-Processors/Macros in Eclipse and ADT plugin

Hi All,

Trying to build an application using eclipse with ADT plugin on
Android. I have quite a few areas which need customization. In C++ we
used to the do the macro/pre-processor way. Using ant scripts I am
able to achieve this nicely. However for debugging purposes and to
leverage the IDE during development, am interested to know if this is
possible to do it using eclipse for android.

Is this possible at all??


3. Made Android TextMate Bundle (Eclipse Plug-In Alternative)

4. Invalidate()?...

5. External peripherals emulating keyboard input

6. onMeasure gets called, but View doesn't change size

7. Caused by: java.io.NotSerializableException: android.os.Message