Android Studio Tip of the Day--Breakpoints

来源:互联网 发布:淘宝怎么找优惠券 编辑:程序博客网 时间:2024/06/11 21:18

<1>Android Studio Tip of the Day: Toggle Breakpoints

The next few tips will be about debugging. So let's start with the most basic one: adding a good old line breakpoint!

I am pretty sure that by now you have debugged an app and know how to toggle it by left-clicking in the left gutter.
Here is the correct shortcut to toggle it without your mouse.
Shortcut: 
 - Mac: Cmd+F8
 - Windows/Linux: Ctrl+F8


View all breakpoints

Shortcut:

-Mac:Shift + Cmd +F8


<2>Android Studio Tip of the Day: Disable Breakpoints

This will disable the breakpoint. Particularly useful when you have some complicated conditional or logging breakpoint that you don't need right now but don't want to recreate next time.
Shortcut: 
  - Mouse: Alt+LeftClick on an existing breakpoint in the left gutter
  - There is no keyboard shortcut but you can create one if you use it often enough.



<3>Android Studio Tip of the Day: Temporary Breakpoints

This is a way to add a breakpoint that will be removed automatically the first time you hit it.
Shortcut: 
  - Mouse: Alt+LeftClick in the left gutter
  - Mac: Cmd+Alt+Shift+F8
  - Windows/Linux: Ctrl+Alt+Shift+F8




<4>Android Studio Tip of the Day: Conditional Breakpoints
In a nutshell, only do break when a certain condition is met. You can enter any java expression that returns a boolean based on the current scope. 
And do enjoy the fact that the condition textbox supports code completion!
Shortcut: 
  - Right click on a breakpoint and enter a condition.



<5>Android Studio Tip of the Day: Logging Breakpoints

This is a breakpoint that logs stuff instead of breaking.
This can be useful when you want to log some stuff right now but cannot or don't want to redeploy with logging code added.
Shortcut: 
  - Right click on a breakpoint, uncheckSuspend and type your message in "Log evaluated Expression"




From:https://plus.google.com/collection/wtO0PB



原创粉丝点击