1 page.title= 2 page.tags= 3 helpoutsWidget=true 4 5 trainingnavtop=true 6 7 @jd:body 8 9 <div id="tb-wrapper"> 10 <div id="tb"> 11 12 <h2> </h2> 13 <ol> 14 <li><a href="#Pause"> </a></li> 15 <li><a href="#Resume"> </a></li> 16 </ol> 17 18 <h2>. :</h2> 19 <ul> 20 <li><a href="{@docRoot}guide/components/activities.html"></a> 21 </li> 22 </ul> 23 24 <h2> </h2> 25 26 <div class="download-box"> 27 <a href="http://developer.android.com/shareables/training/ActivityLifecycle.zip" class="button"> </a> 28 <p class="filename">ActivityLifecycle.zip</p> 29 </div> 30 31 </div> 32 </div> 33 34 <p> 35 , <em></em>. , 36 ( ) . 37 , , .</p> 38 39 <p> , <em></em> ( 40 ).</p> 41 42 <p> , {@link 43 android.app.Activity#onPause onPause()} {@link android.app.Activity}, 44 , ( ), 45 , . 46 , 47 {@link android.app.Activity#onResume onResume()}.</p> 48 49 <p class="note"><strong>.</strong> {@link 50 android.app.Activity#onPause()}, , 51 . 52 .</p> 53 54 <img src="{@docRoot}images/training/basics/basic-lifecycle-paused.png" /> 55 <p class="img-caption"><strong> 1</strong>. 56 , {@link android.app.Activity#onPause onPause()} 57 (1). , , 58 {@link android.app.Activity#onResume onResume()} (2).</p> 59 60 61 <h2 id="Pause"> </h2> 62 63 <p> {@link android.app.Activity#onPause()} , 64 , . , 65 , . 66 {@link android.app.Activity#onPause()} :</p> 67 68 <ul> 69 <li> , .</li> 70 <li> , 71 ( ).</li> 72 <li> , , ( 73 GPS) , 74 .</li> 75 </ul> 76 77 <p>, {@link android.hardware.Camera}, 78 {@link android.app.Activity#onPause()} .</p> 79 80 <pre> 81 @Override 82 public void onPause() { 83 super.onPause(); // Always call the superclass method first 84 85 // Release the Camera because we don't need it when paused 86 // and other activities might need to use it. 87 if (mCamera != null) { 88 mCamera.release() 89 mCamera = null; 90 } 91 } 92 </pre> 93 94 <p> <strong></strong> {@link android.app.Activity#onPause()} 95 ( ) . 96 {@link android.app.Activity#onPause()} 97 , ( ). 98 {@link 99 android.app.Activity#onPause()} , , 100 ( 101 {@link android.app.Activity#onStop onStop()}).</p> 102 103 <p> , {@link android.app.Activity#onPause 104 onPause()}, , 105 .</p> 106 107 <p class="note"><strong>.</strong> {@link 108 android.app.Activity} . 109 , 110 .</p> 111 112 113 114 <h2 id="Resume"> </h2> 115 116 <p> , {@link 117 android.app.Activity#onResume()}.</p> 118 119 <p>, , , 120 . , {@link 121 android.app.Activity#onResume()} , {@link 122 android.app.Activity#onPause()}, , 123 ( , 124 ).</p> 125 126 <p> {@link android.app.Activity#onResume()} 127 {@link android.app.Activity#onPause()} . , 128 .</p> 129 130 <pre> 131 @Override 132 public void onResume() { 133 super.onResume(); // Always call the superclass method first 134 135 // Get the Camera instance as the activity achieves full user focus 136 if (mCamera == null) { 137 initializeCamera(); // Local method to handle camera init 138 } 139 } 140 </pre> 141 142 143 144 145 146 147 148