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[]
{"92soc...@gmail.com"});
        sendIntent.putExtra(Intent.EXTRA_TEXT, body);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        sendIntent.setType("message/rfc822");
        Intent i = Intent.createChooser(sendIntent, "Title:");
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  // because
Service ...
        _context.startActivity(i);
  }
}

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: 
 http://www.anddev.org/email_send_intent_intentchooser-t3295.html 
?

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 ;(

        try
        {
            _context.startActivity(i);
            Log.d(LOG_TAG, "startActivity() called");
        } catch (Exception e)
        {
            e.printStackTrace();
        }

below is my logcat log

WARN/dalvikvm(582): threadid=3: thread exiting with uncaught exception
(group=0x4001b188)
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
android.app.ActivityThread.handleCreateService(ActivityThread.java:
2790)
ERROR/AndroidRuntime(582):     at android.app.ActivityThread.access
$3200(ActivityThread.java:119)
ERROR/AndroidRuntime(582):     at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1917)
ERROR/AndroidRuntime(582):     at
android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(582):     at android.os.Looper.loop(Looper.java:
123)
ERROR/AndroidRuntime(582):     at
android.app.ActivityThread.main(ActivityThread.java:4363)
ERROR/AndroidRuntime(582):     at
java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(582):     at
java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(582):     at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
ERROR/AndroidRuntime(582):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
ERROR/AndroidRuntime(582):     at
dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(582): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(582):     at
com.my.service.onCreate(ISPService.java:230)
ERROR/AndroidRuntime(582):     at
android.app.ActivityThread.handleCreateService(ActivityThread.java:
2780)
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

Hi,

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
again?

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

Thanks for your help!

RodgerWilko!

-- 

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?