考虑BlackBerry的移动手持设备特征的限制,BlackBerry有很多功能,是类似J2ME的,比如对exception的一个常见功能 callstack支持,
由于j2me不支持管道流,无法像J2SE那样把调用栈打出,不过BB提供的内置的event log,可以通过答应throwable的callstack,这样自动就可以打印输出到系统日志,然后导出,就可以。
实例代码如下,
。。。。。
catch (Throwable e) {
//Dialog.inform("exception");
System.err.println("io execption");
long GUID = 0x9999999999999999L;
EventLogger.register(GUID, "LMLogger", EventLogger.VIEWER_STRING);
String eventData = "smsApp: sms1";
EventLogger.logEvent(GUID, eventData.getBytes() , EventLogger.ALWAYS_LOG);
e.printStackTrace();
}
long GUID = 0x9999999999999999L;
EventLogger.register(GUID, "LMLogger", EventLogger.VIEWER_STRING);
String eventData = "smsApp: sms2";
EventLogger.logEvent(GUID, eventData.getBytes() , EventLogger.ALWAYS_LOG);
最后在系统的event log中,可以看到如下输出,
guid:0x9C3CD62E3320B498 time: Thu Jun 17 17:09:03 2010 severity:1 type:3 app:Java Exception data:
RuntimeException
blocking operation not permitted on event dispatch thread
net_rim_cldc-19(4BAE2663)
EventThreadCheck
throwException
0x1F87
net_rim_cldc-18(4BAE2663)
NativeTransport
send
0x76D1
net_rim_cldc-19(4BAE2663)
Transport
send
0x9266
net_rim_cldc-19(4BAE2663)
Protocol
send
0x3702
Smsfor8910(4C19EC08)
Smsfor8910RIMResources
<clinit>
0x114
net_rim_cldc-11(4BAE2663)
Field
fieldChangeNotify
0xBCD
net_rim_cldc-14(4BAE2663)
ButtonField
<private>
0x270C
net_rim_cldc-14(4BAE2663)
ButtonField
trackwheelUnclick
0x22E0
net_rim_cldc-12(4BAE2663)
Manager
trackwheelUnclick
0x249D
net_rim_cldc-12(4BAE2663)
Manager
trackwheelUnclick
0x249D
net_rim_cldc-12(4BAE2663)
Screen
trackwheelUnclick
0x9693
net_rim_cldc-12(4BAE2663)
Screen
dispatchNavigationEvent
0x71CD
net_rim_cldc-13(4BAE2663)
UiEngineImpl
processMessage
0x7964
net_rim_cldc-8(4BAE2663)
Application
<private>
0x29A4
net_rim_cldc-8(4BAE2663)
Application
processNextMessage
0x1ADD
net_rim_cldc-8(4BAE2663)
Application
enterEventDispatcher
0x1A1A
Smsfor8910(4C19EC08)
MyThread
run
0x9A
这样看来,BB的对Java支持,其实是非常强大的,可惜很多人不知道罢了。
分享自salvatore_zhang的博客:http://blog.csdn.net/salvatore_zhang/archive/2010/06/18/5678916.aspx
------解决思路----------------------
好东西,可惜不太懂