One of the simplest, but nevertheless the most useful debugging, techniques is the simple inclusion of a Logcat filter. This can be used to report variable values or simply keep track of which methods are being called. This is of particular use when keeping track of processes that are not visibly apparent, such as services, broadcast receivers and callbacks that have no obvious impact on the UI.
Perhaps the very simplest debug tool available, and useful when we are in a hurry and just want to check for a single value or event, is to include a line like:
System.out.println("Something happened here");
This is only an on the fly solution as the output will be buried in among the rest of the Logcat text. Far easier to manage is to configure a Logcat filter. The following short exercise demonstrates how this is done:
- Start a new project, or open a new one...