Example usage for android.os ServiceManager checkService

List of usage examples for android.os ServiceManager checkService

Introduction

In this page you can find the example usage for android.os ServiceManager checkService.

Prototype

@UnsupportedAppUsage
public static IBinder checkService(String name) 

Source Link

Document

Retrieve an existing service called @a name from the service manager.

Usage

From source file:com.android.tv.settings.accessories.AddAccessoryActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setLayoutProperties(R.layout.add_accessory_custom_two_pane_dialog, R.id.content_fragment,
            R.id.action_fragment);// ww  w .  j a va2  s .  com

    super.onCreate(savedInstanceState);

    mDreamManager = IDreamManager.Stub.asInterface(ServiceManager.checkService(DreamService.DREAM_SERVICE));

    mFragmentManager = getFragmentManager();

    mBtDevices = new ArrayList<BluetoothDevice>();

    mActions = new ArrayList<Action>();

    mNoInputMode = getIntent().getBooleanExtra(INTENT_EXTRA_NO_INPUT_MODE, false);
    mHwKeyDown = false;

    mActions.clear();

    mActionFragment = ActionFragment.newInstance(mActions);
    mContentFragment = AddAccessoryContentFragment.newInstance(false);
    setContentAndActionFragments(mContentFragment, mActionFragment);
    mShowingMultiFragment = false;

    mActionsAnimationDone = false;
    mFragmentTransactionPending = false;
}

From source file:com.android.contacts.activities.DialtactsActivity.java

/**
 * Returns true if the intent is due to hitting the green send key (hardware call button:
 * KEYCODE_CALL) while in a call./*from w w w.  java 2  s .co m*/
 *
 * @param intent the intent that launched this activity
 * @param recentCallsRequest true if the intent is requesting to view recent calls
 * @return true if the intent is due to hitting the green send key while in a call
 */
private boolean isSendKeyWhileInCall(final Intent intent, final boolean recentCallsRequest) {
    // If there is a call in progress go to the call screen
    if (recentCallsRequest) {
        final boolean callKey = intent.getBooleanExtra("call_key", false);

        try {
            ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
            if (callKey && phone != null && phone.showCallScreen()) {
                return true;
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to handle send while in call", e);
        }
    }

    return false;
}