YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Debug Breakpoints - Developing Android Apps

Get Embed Code
10 Languages

Showing Revision 16 created 05/25/2016 by Udacity Robot.

  1. I'll show you how we can add
    breakpoints in our code.
  2. Go ahead and click on the screen bug icon
    to attach the debugger.
  3. We'll go to the Settings menu.
    In the SettingsActivity,
  4. I'm going to add two breakpoints
    in the onPreferenceChange method.
  5. I'm going to add a breakpoint at line 59
    in the case of a ListPreference
  6. when it's about to set the summary.
  7. I'm also going to add a breakpoint
    at line 63 when it's not a ListPreference
  8. and it sets the summary.
    Let's go into the app to try it out.
  9. Tap on the Location
    and change the postal code.
  10. If you hit OK then it triggers
    the breakpoint to stop right here.
  11. These are the values
    of the variables at this time,
  12. and we see the new postal code here.
    You can step over or into the method
  13. for more details, or you can hit Play
    to continue, or Stop to stop the debugger.
  14. Let's hit Play to continue. And then
    we see that the UI has been updated
  15. so that the preference summary
    is the new postal code.
  16. Let's try it for Temperature Units.
    We tap here, and then select Imperial.
  17. It triggers this breakpoint
    in the ListPreference case.
  18. We hit Play to continue,
    and then we see
  19. that Imperial is now
    the preference summary.