Email a Crash report from a BlackBerry App
Too often, I get a email from a user who downloaded an app saying, “my app crashed, help”, and it’s very hard to diagnose the problem if you can’t re-create the problem on your own device. So, I thought of adding a crash report screen to my BlackBerry Webworks app.
Since I use “Console.log” statements all over my apps when developing the app, then the diagnostic information is already there.
All I needed to do is declare a global variable, and then replace all my console.log’s with log(string), and then have log(string) add to this global variable. Have this visible in a <pre> tag within a page to display a crash report, like shown opposite.
The clever bit, is then to have this send an email:
function email(to, subject, body) {
var message = to + ‘?subject=’ + subject + ‘&body=’ + body;
blackberry.invoke.invoke({
target: ‘sys.pim.uib.email.hybridcomposer’,
action: ‘bb.action.OPEN, bb.action.SENDMAIL’,
type: ‘message/rfc822’,
uri: ‘mailto:’ + message
});
}Which is taken from the BuiltForBlackBerry Bootstrap on Github.