Thanks. I'm saving your email to hopefully use it.
On Apr 11, 2009, at 11:52 AM, Mariano Kamp <[email protected]> wrote:
Here is mine - no cleanup / enhancements, right from my repository. Really
basic stuff. And it doesn't work in the emulator as there is no email activity.
package com.newsrob;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.regex.Pattern;
import android.app.Application;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
public class NewsRob extends Application {
private static final String TAG = NewsRob.class.getSimpleName();
public static final boolean DEBUG = false;
@Override
public void onCreate() {
super..onCreate();
Log.d(TAG, "NewsRob.onCreate()");
new
NewsRobDefaultExceptionHandler(EntryManager.getInstance(NewsRob.this));
}
@Override
public void onTerminate() {
Log.d(TAG, "NewsRob.onTerminate()");
super.onTerminate();
}
}
class NewsRobDefaultExceptionHandler implements Thread.UncaughtExceptionHandler
{
private EntryManager entryManager;
private UncaughtExceptionHandler oldDefaultExceptionHandler;
private static final String TAG =
NewsRobDefaultExceptionHandler.class.getSimpleName();
NewsRobDefaultExceptionHandler(EntryManager entryManager) {
this.entryManager = entryManager;
Log.d(TAG, "Default Exception Handler=" +
Thread.getDefaultUncaughtExceptionHandler());
oldDefaultExceptionHandler =
Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(this);
}
public void uncaughtException(Thread t, Throwable e) {
Log.e("NewsRob", "Caught the following exception: ", e);
StringBuilder message = new StringBuilder(
"Sorry!\n\nNewsRob hit a wall. Please send this
mail, so that the developer can analyze/fix the issue.\nIf it is not too much
to ask, please add to this mail what you just did:\n\n");
message.append(String.format("-- NewsRob Version: %s/%s\n",
entryManager.getMyVersionName(),
entryManager.getMyVersionCode()));
message.append(String.format("-- Android Version: sdk=%s,
release=%s, inc=%s\n", Build.VERSION.SDK,
Build.VERSION.RELEASE,
Build.VERSION.INCREMENTAL));
message.append(String.format("-- Thread State: %s\n",
t.getState()));
Job j = entryManager.getCurrentRunningJob();
if (j != null)
message.append(String.format("-- Job: %s\n",
j.getJobDescription()));
if (entryManager.runningThread != null)
message.append(String.format("-- Running Thread: %s\n",
entryManager.runningThread));
// Add stacktrace
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.close();
message.append("-- Stacktrace:\n");
message.append(sw.getBuffer());
String messageBody = message.toString();
// ignore certain exceptions
if
(Pattern.compile("CacheManager.java:391").matcher(messageBody).find())
return;
// Prepare Mail
final Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.setType("message/rfc822");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {
"[email protected]" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "BugReport: " +
e.getClass().getSimpleName() + ": "
+ e.getMessage());
sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);
Log.e(TAG, "Exception handled. Email activity should be
initiated now..");
// Send Mail
new Thread(new Runnable() {
public void run() {
entryManager.getContext().startActivity(sendIntent);
}
}).start();
Log.e(TAG, "Exception handled. Email should be sent by now.");
// Use default exception mechanism
if (oldDefaultExceptionHandler != null)
oldDefaultExceptionHandler.uncaughtException(t, e);
}
}
On Sat, Apr 11, 2009 at 5:30 PM, Mattaku Betsujin <[email protected]>
wrote:
Hello Mike,
Could you share how you implemented the bug report mechanism? How can you get a
stack trace when the app crashes inside the UI thread?
Thanks
On Sat, Apr 11, 2009 at 6:51 AM, Mike Hearn <[email protected]> wrote:
I really question what developers are doing to get so many F/C
comments (and I see them on other apps all the time).
I have a crash/bug reporter integrated into my app. It's not a very
good one - it just uploads exception stacktraces and some data to my
server when the core logic code crashes, so it doesn't even cover UI
bugs.
I have hundreds of reports from the wild (about 25k downloads). So
obviously my app does fail. Yet, the comments on the app are all
glowing, and people are remarkably willing to give 4 or 5 stars even
when it didn't do quite what they wanted. I really wonder about the
buggyness of apps that get significant numbers of F/C comments.
It must be frustrating to see comments about bugs that you can't
reproduce, but at the same time, I think some people here believe
writing software is easy. It's hard. I did all kinds of testing with
my app, including disrupting its network connection at various points
as it runs, repeatedly sliding the screen to force activity
reconstruction etc. Some bugs still slipped through, fortunately the
crash reports identify them quite well as most people with problems
will never even leave a comment, let alone email you to help you
figure out the problem.
cause you are subscribed to the Google Groups "Android Discuss" 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-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Android Discuss" 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-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---