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