Looks like he is doing this:


 public void uncaughtException(Thread t, Throwable e) {
        Log.e(ACRA.LOG_TAG,
                "ACRA caught a " + e.getClass().getSimpleName() + " 
exception for " + mContext.getPackageName()
                        + ". Building report.");
        // Generate and send crash report
        ReportsSenderWorker worker = handleException(e);

        if (mReportingInteractionMode == ReportingInteractionMode.TOAST) {
            try {
                // Wait a bit to let the user read the toast
                Thread.sleep(4000);
            } catch (InterruptedException e1) {
                Log.e(LOG_TAG, "Error : ", e1);
            }
        }

        if (worker != null) {
            while (worker.isAlive()) {
                try {
                    // Wait for the report sender to finish it's task before
                    // killing the process
                    Thread.sleep(100);
                } catch (InterruptedException e1) {
                    Log.e(LOG_TAG, "Error : ", e1);
                }
            }
        }

        if (mReportingInteractionMode == ReportingInteractionMode.SILENT) {
            // If using silent mode, let the system default handler do it's 
job
            // and display the force close dialog.
            mDfltExceptionHandler.uncaughtException(t, e);
        } else {
            // If ACRA handles user notifications whit a Toast or a 
Notification
            // the Force Close dialog is one more notification to the 
user...
            // We choose to close the process ourselves using the same 
actions.
            CharSequence appName = "Application";
            try {
                PackageManager pm = mContext.getPackageManager();
                appName = pm.getApplicationInfo(mContext.getPackageName(), 
0).loadLabel(mContext.getPackageManager());
                Log.e(LOG_TAG, appName + " fatal error : " + 
e.getMessage(), e);
            } catch (NameNotFoundException e2) {
                Log.e(LOG_TAG, "Error : ", e2);
            } finally {
                android.os.Process.killProcess(android.os.Process.myPid());
                System.exit(10);
            }
        }
    }


Not sure if this is good since he calls System.exit, which I was told never 
to call.



On Monday, September 10, 2012 1:20:17 PM UTC-5, RichardC wrote:
>
> Have a look at source for ACRA
> http://code.google.com/p/acra/ 
>
> On Monday, September 10, 2012 7:08:24 PM UTC+1, bob wrote:
>>
>>
>> Can someone help me see what a *good* Android UncaughtExceptionHandler 
>> looks like?
>>
>> I wrote this, but I suspect it is bad:
>>
>> public class BSOD_Exception_Handler implements UncaughtExceptionHandler {
>>
>> @Override
>> public void uncaughtException(Thread thread, Throwable ex) {
>>
>> BSOD.show_blue_screen(MainActivity.act, ex.getMessage());
>> MainActivity.act.finish();
>> }
>>
>> }
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to