Kenji Kenji - 9 months ago 39
Android Question

is there any way to conditional Debugging in android studio

is there any way to have conditional Debug in android studio?
for example I wanna go to debug mode when a specific variable value is.
for example:

for(MyClass myclass: ClassList){
String title = myclass.gettitle(); // this is where break point is

before that I do not need the debug mode. I just wanna examine the app on that exact value. for example when
" in this case I should check the variable value and if it is not my required value I should press F9 to go to next value. maybe this takes 50 times to get to my desired value.

I already know that I can put a condition in code and put breake point in that

for(MyClass myclass: ClassList){
String title = myclass.gettitle();
//put break point here

but I think this is not good and clean way and for each condition you had to change your code. I wonder if I could pop debug mode in condition it will be very exiting.

Answer Source

It is possible to add a condition for a breakpoint. Add a breakpoint, as you normally do, and click with the right mouse button on it. You will be prompt with a dialog. In the condition you can put some java code.

E.g. you could put "kickBoxing".equals(title)

this way the debugger will stop on that breakpoint only when the condition is true.

enter image description here

(photo taken from