Example usage for android.content Intent EXTRA_DOCK_STATE_UNDOCKED

List of usage examples for android.content Intent EXTRA_DOCK_STATE_UNDOCKED

Introduction

In this page you can find the example usage for android.content Intent EXTRA_DOCK_STATE_UNDOCKED.

Prototype

int EXTRA_DOCK_STATE_UNDOCKED

To view the source code for android.content Intent EXTRA_DOCK_STATE_UNDOCKED.

Click Source Link

Document

Used as an int value for android.content.Intent#EXTRA_DOCK_STATE to represent that the phone is not in any dock.

Usage

From source file:com.slushpupie.deskclock.DeskClock.java

public DeskClock() {
    super();//from w  w w  .  j  a v  a  2s . co m
    // determine if multitouch is really supported
    try {
        getXMethod = MotionEvent.class.getMethod("getX", new Class[] { int.class });
        getYMethod = MotionEvent.class.getMethod("getY", new Class[] { int.class });
        supportMultiTouch = true;
    } catch (NoSuchMethodException nsme) {
        supportMultiTouch = false;
    }

    intentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();

            if (Intent.ACTION_DOCK_EVENT.equals(action)) {
                int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, 0);
                switch (dockState) {
                case Intent.EXTRA_DOCK_STATE_UNDOCKED:
                    Log.d(LOG_TAG, "received EXTRA_DOCK_STATE_UNDOCKED");
                    if (prefsUndockExit)
                        finish();
                    else
                        Log.d(LOG_TAG, "Ignoring...");
                    break;
                case Intent.EXTRA_DOCK_STATE_DESK:
                    Log.d(LOG_TAG, "received EXTRA_DOCK_STATE_DESK");
                    break;
                }
            }
            if (Intent.ACTION_TIME_TICK.equals(action)) {
                updateTime();
            }
        }
    };
}