Kenji Kenji - 3 months ago 18
Android Question

is there any way to conditional Debug 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.


You can do that with Android Studio:

  1. Set a breakpoint on the line you need.
  2. Right-click on the breakpoint
  3. Paste your condition into the field named Condition

For example, your condition should be like myclass.gettitle().equals("KickBoxing")