1 page.title= 2 parent.title= 3 parent.link=index.html 4 5 trainingnavtop=true 6 previous.title= 7 previous.link=battery-monitoring.html 8 next.title= 9 next.link=connectivity-monitoring.html 10 11 @jd:body 12 13 <div id="tb-wrapper"> 14 <div id="tb"> 15 16 <h2></h2> 17 <ol> 18 <li><a href="#CurrentDockState"></a></li> 19 <li><a href="#DockType"></a></li> 20 <li><a href="#MonitorDockState"></a></li> 21 </ol> 22 23 24 <h2></h2> 25 <ul> 26 <li><a href="{@docRoot}guide/components/intents-filters.html">intent intent </a> 27 </ul> 28 29 </div> 30 </div> 31 32 <p>Android </p> 33 34 <p></p> 35 36 <p> {@link android.content.Intent} </p> 37 38 39 <h2 id="CurrentDockState"></h2> 40 41 <p> {@link android.content.Intent#ACTION_DOCK_EVENT} {@link android.content.BroadcastReceiver} {@code null} {@link android.content.Context#registerReceiver registerReceiver()} </p> 42 43 <pre>IntentFilter ifilter = new IntentFilter(Intent.ACTION_DOCK_EVENT); 44 Intent dockStatus = context.registerReceiver(null, ifilter);</pre> 45 46 <p> {@code EXTRA_DOCK_STATE} <p> 47 48 <pre>int dockState = battery.getIntExtra(EXTRA_DOCK_STATE, -1); 49 boolean isDocked = dockState != Intent.EXTRA_DOCK_STATE_UNDOCKED;</pre> 50 51 52 <h2 id="DockType"></h2> 53 54 <p> 55 <ul><li></li> 56 <li></li> 57 <li></li> 58 <li></li></ul></p> 59 60 <p> API 11 Android</p> 61 62 <pre>boolean isCar = dockState == EXTRA_DOCK_STATE_CAR; 63 boolean isDesk = dockState == EXTRA_DOCK_STATE_DESK || 64 dockState == EXTRA_DOCK_STATE_LE_DESK || 65 dockState == EXTRA_DOCK_STATE_HE_DESK;</pre> 66 67 68 <h2 id="MonitorDockState"></h2> 69 70 <p> {@link android.content.Intent#ACTION_DOCK_EVENT} </p> 71 72 <pre><action android:name="android.intent.action.ACTION_DOCK_EVENT"/></pre> 73 74 <p></p> 75