"Finish" Activity from Dialog... Not finishing

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


Sponsored Links
 Hi,

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
setup:

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

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/
qwerty.kcm.bin
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
InputConnection
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?

Thanks,
-Shemmy

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. how to monitor sim has been changed?

Anybody please help me writing this application.
Actually I am writing one application using that the application is
runs when power is on and check for the IMSI number. If we have
changed the sim card then imsi number is also get changed, then one
sms is send from that new sim card to one number.

Actually I write application that runs on every boot, I know how to
send the sms, how to calculate IMSI number.

But I don't know how to compare the IMSI number,i.e how and where to
store IMSI number the one which is exist at the time of application
installed.

-- 

2. if second application installed on phone then first will not found

when I had tried to install any application for the first time , it
gives me following error as.


D:\Pramod Backup\android\android-sdk-windows\tools>adb install
pramod.apk
77 KB/s (8628 bytes in 0.109s)
pkg: /data/local/tmp/pramod.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]


But there is no pramod.apk file is present in phone , but if I install
the application using -l -r as

D:\Pramod Backup\android\android-sdk-windows\tools>adb install -l -r
pramod.apk
38 KB/s (8628 bytes in 0.218s)
pkg: /data/local/tmp/pramod.apk
Success

It will installed application succesfully. Why is it so?

and when I tried another application to install as


D:\Pramod Backup\android\android-sdk-windows\tools>adb install -l -r
Final.apk
38 KB/s (8628 bytes in 0.218s)
pkg: /data/local/tmp/Final.apk
Success

then previous application (i.e here pramod.apk) not shown in phone.

-- 

3. Displaying Virtual Keyboard without expanding EditText

4. Spare Part, Suku Cadang, Komponen-komponen Android G1

5. Internet connection

6. Unable to configure emulator network

7. How to create txt file in android programatically?