Skip to content

Commit d9c3e14

Browse files
committed
Added a way to print stack traces on Android
1 parent 6509bb9 commit d9c3e14

File tree

4 files changed

+234
-196
lines changed

4 files changed

+234
-196
lines changed

CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8724,6 +8724,22 @@ public void announceForAccessibility(Component cmp, String text) {
87248724
// should override this method.
87258725
}
87268726

8727+
/**
8728+
* Returns the stack trace from the exception on the given
8729+
* thread. This API isn't supported on all platforms and may
8730+
* return a blank string when unavailable.
8731+
*
8732+
* @param parentThread the thread in which the exception was thrown
8733+
* @param t the exception
8734+
* @return a stack trace string that might be blank
8735+
*/
8736+
public String getStackTrace(Thread parentThread, Throwable t) {
8737+
if (parentThread instanceof CodenameOneThread && ((CodenameOneThread) parentThread).hasStackFrame()) {
8738+
return ((CodenameOneThread) parentThread).getStack(t);
8739+
}
8740+
return "";
8741+
}
8742+
87278743
class RPush implements Runnable {
87288744
public void run() {
87298745
final long pushId = Preferences.get("push_id", (long) -1);

CodenameOne/src/com/codename1/ui/Display.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,19 @@ void mainEDTLoop() {
11181118
INSTANCE.edt = null;
11191119
}
11201120

1121+
/**
1122+
* Returns the stack trace from the exception on the given
1123+
* thread. This API isn't supported on all platforms and may
1124+
* return a blank string when unavailable.
1125+
*
1126+
* @param parentThread the thread in which the exception was thrown
1127+
* @param t the exception
1128+
* @return a stack trace string that might be blank
1129+
*/
1130+
public String getStackTrace(Thread parentThread, Throwable t) {
1131+
return impl.getStackTrace(parentThread, t);
1132+
}
1133+
11211134
/**
11221135
* Implementation of the event dispatch loop content
11231136
*/

0 commit comments

Comments
 (0)