i can't send email in UncaughtExceptionHandler for Service

by codefish » Thu, 22 Jul 2010 11:48:02 GMT

Sponsored Links
 i want to handle exceptions in Service.
my exception handler sends error report email.
so i add FLAG_ACTIVITY_NEW_TASK flag and it works fine in onCreate().
but in UncaughtExceptionHandler, it doesn't send email.

so how it can send email in uncaughtException()?

public class ErrorReporter implements Thread.UncaughtExceptionHandler
  public void uncaughtException(Thread t, Throwable e) {
    // ...
    SendErrorMail(this.CurContext, Report);

  private void SendErrorMail(Context _context, String ErrorContent) {
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        String subject = ("Crash Report - Android ErrorReporter");
        String body = ErrorContent + "\n\n";
        sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]
        sendIntent.putExtra(Intent.EXTRA_TEXT, body);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        Intent i = Intent.createChooser(sendIntent, "Title:");
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  // because
Service ...

thank you


i can't send email in UncaughtExceptionHandler for Service

by DanH » Thu, 22 Jul 2010 20:40:59 GMT

 First off, are you sure that your UncaughtExceptionHandler is not
throwing an exception?


Sponsored Links

i can't send email in UncaughtExceptionHandler for Service

by Joseph Earl » Fri, 23 Jul 2010 03:30:39 GMT

 You email is not getting sent because you are not doing anything with
your sendIntent. You create it but then never use it.


i can't send email in UncaughtExceptionHandler for Service

by Joseph Earl » Fri, 23 Jul 2010 03:34:33 GMT

 Scratch that. My mistake. I missed the Intent.createChooser line.
Have you taken a look at: 

I don't see any immediate errors in your code.


i can't send email in UncaughtExceptionHandler for Service

by codefish » Thu, 29 Jul 2010 19:45:45 GMT

 thank you for your reply
I added try/catch code but I got no exception
and it still doesn't send a email ;(

            Log.d(LOG_TAG, "startActivity() called");
        } catch (Exception e)

below is my logcat log

WARN/dalvikvm(582): threadid=3: thread exiting with uncaught exception
DEBUG/ErrorReporter(582): uncaughtException() tThread[main,5,main],
except:java.lang.RuntimeException: Unable to create service
com.my.service: java.lang.NullPointerException
INFO/ActivityManager(53): Starting activity: Intent
{ act=android.intent.action.CHOOSER flg=0x10000000 cmp=android/
com.android.internal.app.ChooserActivity (has extras) }
DEBUG/ErrorReporter(582): startActivity() called
ERROR/AndroidRuntime(582): Uncaught handler: thread main exiting due
to uncaught exception
ERROR/AndroidRuntime(582): java.lang.RuntimeException: Unable to
create service com.my.service: java.lang.NullPointerException
ERROR/AndroidRuntime(582):     at
ERROR/AndroidRuntime(582):     at android.app.ActivityThread.access
ERROR/AndroidRuntime(582):     at android.app.ActivityThread
ERROR/AndroidRuntime(582):     at
ERROR/AndroidRuntime(582):     at android.os.Looper.loop(Looper.java:
ERROR/AndroidRuntime(582):     at
ERROR/AndroidRuntime(582):     at
java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(582):     at
ERROR/AndroidRuntime(582):     at com.android.internal.os.ZygoteInit
ERROR/AndroidRuntime(582):     at
ERROR/AndroidRuntime(582):     at
dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(582): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(582):     at
ERROR/AndroidRuntime(582):     at
ERROR/AndroidRuntime(582):     ... 10 more
INFO/Process(53): Sending signal. PID: 582 SIG: 3
INFO/dalvikvm(582): threadid=7: reacting to signal 3
INFO/dalvikvm(582): Wrote stack trace to '/data/anr/traces.txt'

I can't know why.


i can't send email in UncaughtExceptionHandler for Service

by Joseph Earl » Thu, 29 Jul 2010 20:06:51 GMT

 Here's your error:

java.lang.NullPointerException at
com.my.service.onCreate(ISPService.java line:230)

Take a look at line 230 of ISPService.java and try and see what could
possibly be null.


Other Threads

1. Selesai update f/w dan rooting gak bisa konek 3

pake kartu apa? soalnya SM1.0.3 itu XXJCE-based (FW Eropa) yang dimana ada
bug APN kalo dipasang sama 3 ato IM2.

Bisa diakali dengan mengcopy file libsec-ril.so dari punyanya DXJC4. Caranya
ada di samsung-android.blogspot.com


2. Continuously scrolling ListActivity


Is it possible to have a list activity that dosen't finish? i.e. if
you scroll to the end of the list then the start of the list begins

It's be best if you could also disable the scroll bar.

Thanks for your help!



3. Configuring automated build scripts

4. Selesai update f/w dan rooting gak bisa konek 3

5. EVO AVA-FROYO + Sense U

6. How should I do this?

7. NSPredicate-like functionality for Collections?