Java Code Examples for android.content.Intent#resolveSystemService()

The following examples show how to use android.content.Intent#resolveSystemService() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void onReceive(final Context context, final Intent broadcastIntent) {
    if (broadcastIntent.getPackage() != null) {
        return;
    }

    try {
        final Intent intent = new Intent(IKeyChainService.class.getName());
        ComponentName service =
                intent.resolveSystemService(getContext().getPackageManager(), 0 /*flags*/);
        if (service == null) {
            return;
        }
        intent.setComponent(service);
        intent.setAction(broadcastIntent.getAction());
        startServiceInBackgroundAsUser(intent, UserHandle.of(getSendingUserId()));
    } catch (RuntimeException e) {
        Slog.e(TAG, "Unable to forward package removed broadcast to KeyChain", e);
    }
}
 
Example 2
boolean doBind(Intent intent, ServiceConnection conn, int flags, UserHandle user) {
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, conn, flags, user)) {
        Slog.e(TAG, "Fail to bind to: " + intent);
        return false;
    }
    return true;
}
 
Example 3
Source Project: android_9.0.0_r45   File: BluetoothA2dp.java    License: Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothA2dp.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            UserHandle.CURRENT_OR_SELF)) {
        Log.e(TAG, "Could not bind to Bluetooth A2DP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 4
boolean doBind() {
    Intent intent = new Intent(IBluetoothA2dpSink.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth A2DP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 5
private boolean doBind() {
    Intent intent = new Intent(IBluetoothPbapClient.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth PBAP Client Service with " + intent);
        return false;
    }
    return true;
}
 
Example 6
boolean doBind() {
    Intent intent = new Intent(IBluetoothMapClient.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth MAP MCE Service with " + intent);
        return false;
    }
    return true;
}
 
Example 7
Source Project: android_9.0.0_r45   File: BluetoothMap.java    License: Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothMap.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth MAP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 8
Source Project: android_9.0.0_r45   File: BluetoothSap.java    License: Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothSap.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth SAP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 9
boolean doBind() {
    Intent intent = new Intent(IBluetoothHealth.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Health Service with " + intent);
        return false;
    }
    return true;
}
 
Example 10
Source Project: android_9.0.0_r45   File: BluetoothPbap.java    License: Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothPbap.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Pbap Service with " + intent);
        return false;
    }
    return true;
}
 
Example 11
boolean doBind() {
    Intent intent = new Intent(IBluetoothAvrcpController.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth AVRCP Controller Service with " + intent);
        return false;
    }
    return true;
}
 
Example 12
boolean doBind() {
    Intent intent = new Intent(IBluetoothHeadsetClient.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Headset Client Service with " + intent);
        return false;
    }
    return true;
}
 
Example 13
boolean doBind() {
    Intent intent = new Intent(IBluetoothHidDevice.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth HID Device Service with " + intent);
        return false;
    }
    Log.d(TAG, "Bound to HID Device Service");
    return true;
}
 
Example 14
Source Project: android_9.0.0_r45   File: BluetoothPan.java    License: Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothPan.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Pan Service with " + intent);
        return false;
    }
    return true;
}
 
Example 15
void doBind() {
    Intent intent = new Intent(IBluetoothHearingAid.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            android.os.Process.myUserHandle())) {
        Log.e(TAG, "Could not bind to Bluetooth Hearing Aid Service with " + intent);
        return;
    }
}
 
Example 16
boolean doBind() {
    Intent intent = new Intent(IBluetoothHidHost.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth HID Service with " + intent);
        return false;
    }
    return true;
}