5

In Intent,there is a constant named ACTION_DOCK_EVENT

Added in API level 5
Broadcast Action: A sticky broadcast for changes in the physical docking state of the device.

What do you mean by docking state?

appersiano
  • 2,670
  • 22
  • 42
Aada
  • 1,591
  • 7
  • 30
  • 57
  • android doc about `dock status` => http://developer.android.com/training/monitoring-device-state/docking-monitoring.html – ahmed hamdy Jul 31 '14 at 16:36

4 Answers4

2

Android devices can be docked into several different kinds of dock devices . These include car or home docks and digital versus analog docks. So when a dock of the device is changed then it throws an intent of ACTION_DOCK_EVENT

If a device is docked, it can be docked in any one of four different type of dock:

  • Car
  • Desk
  • Low-End (Analog) Desk
  • High-End (Digital) Desk

resource here

stinepike
  • 54,068
  • 14
  • 92
  • 112
1

what do you mean by docking state

Docking state means generally your charging state,it may be a car,home dock,digital or analog docks,Android devices can be docked into several different kinds of docks.

Determine the Current Docking State

The dock-state details are included as an extra in a sticky broadcast of the ACTION_DOCK_EVENT action. Because it's sticky, you don't need to register a BroadcastReceiver. You can simply call registerReceiver() passing in null as the broadcast receiver as shown in the next snippet.

IntentFilter ifilter = new IntentFilter(Intent.ACTION_DOCK_EVENT);
Intent dockStatus = context.registerReceiver(null, ifilter);
Abhijit Chakra
  • 3,201
  • 37
  • 66
0

The dock-state details are included as an extra in a sticky broadcast of the ACTION_DOCK_EVENT action. Because it's sticky, you don't need to register a BroadcastReceiver. You can simply call registerReceiver() passing in null as the broadcast receiver as shown in the next snippet.

        mContext = getApplicationContext();
        IntentFilter ifilter = new IntentFilter(Intent.ACTION_DOCK_EVENT);
        Intent dockStatus = registerReceiver(null, ifilter);

You can extract the current docking status from the EXTRA_DOCK_STATE extra:

        int dockState = (dockStatus == null ?
            Intent.EXTRA_DOCK_STATE_UNDOCKED :
            dockStatus.getIntExtra(Intent.EXTRA_DOCK_STATE, -1));
        boolean isDocked = dockState != Intent.EXTRA_DOCK_STATE_UNDOCKED;
        boolean isCar = dockState == Intent.EXTRA_DOCK_STATE_CAR;

Whenever the device is docked or undocked, the ACTION_DOCK_EVENT action is broadcast. To monitor changes in the device's dock-state, simply register a broadcast receiver in your application manifest as shown in the snippet below: action android:name="android.intent.action.ACTION_DOCK_EVENT"

Hope this helps.

  • Welcome to SO! You should add a bit more explanation in an answer, either as a separate paragraph shortly telling what the code does, or as comments within the code. In other words, "working code" for what purpose, doing what? – hyde Mar 01 '14 at 16:05
  • 1
    This does not answer the question asked. In Android what do you mean by docking state? This does not require writing codes – user3144836 May 31 '15 at 02:24
0

From GeeksForGeeks post:

A docking station is a device that is competent in communicating with the Android kernel to fire docking-related events and revise the docking file state. A docking station can make the system and apps do anything that is programmed. One example is showing a different layout on the docked state. It may also open a music player app, play music automatically on desk mode if it is programmed as such, open a map/navigation app in car mode, etc. Dock Mode is different on different phones, but it often turns your phone into a desk clock, photo slideshow viewer, or music player. You can also set it as a speakerphone when you receive calls. The dock is built into self-amplified speakers or music boxes, or it is a stand-alone unit that connects via USB to a computer, charger, or home theater equipment. Some docks use USB for charging and Bluetooth for playing music. This mode is a feature that can be detected on some phones, including many of the Samsung phones, but is not a feature detect on every phone or every version of a phone. For example, Samsung Galaxy S2, S3, and S4 have a dock mode, but the S5 does not. Please check your phone features to make sure your phone is equipped with dock mode.

Asahi
  • 13,378
  • 12
  • 67
  • 87