Well what I am basically doing is an app which has many activities. I have a few friends with android phones and I gave them the app for testing. However, it sometimes goes into endless cycles and does strange behaviour which I am not able to understand due to their lack of programming experience and inability to dump the logcat in those particular moments.
So what I need to do is to create a static always visible window, probably popup window, that shows in which method is the program now.
So my question would be, which is the best way to achieve this functionality and how to retrieve the current method the App is in (it has several threads).
Thread.currentThread().getStackTrace()[1].getMethodName()
You can try this:
public String getCurrentMethod(){
try{
throw new Exception("");
}catch(Exception e){
return e.getStackTrace()[0].toString();
}
return ""; // This never happens
}
It will return something like this:ClassName.methodName():123
There are many answers for this if you search SO. This is a simple method
String name = new Object(){}.getClass().getEnclosingMethod().getName();
You should refer this post. Getting the name of the current executing method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With