1page.title=Notepad Extra Credit 2parent.title=Notepad Tutorial 3parent.link=index.html 4@jd:body 5 6 7<p><em>In this exercise, you will use the debugger to look at the work you did 8in Exercise 3. This exercise demonstrates:</em></p> 9<ul> 10<li><em>How to set breakpoints to observe execution</em> </li> 11<li><em>How to run your application in debug mode</code></em></li> 12</ul> 13 14<div style="float:right;white-space:nowrap"> 15 16 [<a href="notepad-ex1.html">Exercise 1</a>] 17 [<a href="notepad-ex2.html">Exercise 2</a>] 18 [<a href="notepad-ex3.html">Exercise 3</a>] 19 <span style="color:#BBB;"> 20 [<a href="notepad-extra-credit.html" style="color:#BBB;">Extra Credit</a>] 21 </span> 22</div> 23 24<h2>Step 1</h2> 25 26<p>Using the working <code>Notepadv3</code>, put breakpoints in the code at the 27 beginning of the <code>onCreate()</code>, <code>onPause()</code>, 28 <code>onSaveInstanceState()</code> and <code>onResume()</code> methods in the 29 <code>NoteEdit</code> class (if you are not familiar with Eclipse, just 30 right click in the narrow grey border on the left of the edit window at the 31 line you want a breakpoint, and select <em>Toggle Breakpoint</em>, you 32should see a blue dot appear).</p> 33 34<h2>Step 2</h2> 35 36<p>Now start the notepad demo in debug mode:</p> 37 38<ol type="a"> 39 <li> 40 Right click on the <code>Notepadv3</code> project and from the Debug menu 41 select <em>Debug As -> Android Application.</em></li> 42 <li> 43 The Android emulator should say <em>"waiting for debugger to connect"</em> 44 briefly and then run the application.</li> 45 <li> 46 If it gets stuck on the waiting... screen, quit the emulator and Eclipse, 47 from the command line do an <code>adb kill-server</code>, and then restart 48Eclipse and try again.</li></ol> 49 50 <h2>Step 3</h2> 51 52<p>When you edit or create a new note you should see the breakpoints getting 53 hit and the execution stopping.</p> 54 55 <h2>Step 4</h2> 56 57<p>Hit the Resume button to let execution continue (yellow rectangle with a 58green triangle to its right in the Eclipse toolbars near the top).</p> 59 60<h2>Step 5</h2> 61 62<p>Experiment a bit with the confirm and back buttons, and try pressing Home and 63 making other mode changes. Watch what life-cycle events are generated and 64when.</p> 65 66<p>The Android Eclipse plugin not only offers excellent debugging support for 67your application development, but also superb profiling support. You can also 68try using <a href="{@docRoot}guide/developing/debugging/debugging-tracing.html">Traceview</a> to profile your application. If your application is running too slow, this can help you 69find the bottlenecks and fix them.</p> 70 71