HidDevice.Open(IExecutor, IOutcomeReceiver) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Opens the HID device so that it can be used to send and receive HID reports.
[Android.Runtime.Register("open", "(Ljava/util/concurrent/Executor;Landroid/os/OutcomeReceiver;)V", "", ApiSince=37)]
[Android.Runtime.RequiresPermission("android.permission.ACCESS_HID")]
public void Open(Java.Util.Concurrent.IExecutor executor, Android.OS.IOutcomeReceiver callback);
[<Android.Runtime.Register("open", "(Ljava/util/concurrent/Executor;Landroid/os/OutcomeReceiver;)V", "", ApiSince=37)>]
[<Android.Runtime.RequiresPermission("android.permission.ACCESS_HID")>]
member this.Open : Java.Util.Concurrent.IExecutor * Android.OS.IOutcomeReceiver -> unit
Parameters
- executor
- IExecutor
The executor on which the callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.
- callback
- IOutcomeReceiver
The object to be notified of success or failure. This value cannot be null.
- Attributes
Remarks
Opens the HID device so that it can be used to send and receive HID reports.
This is an asynchronous operation. If an open operation is already in progress, the provided callback is queued and will be notified once the underlying operation completes. The state transitions are as follows:
If the device is already opened, callback.onResult is invoked immediately.
If the device is currently opening, the request is queued and callback will be notified when the existing operation finishes.
If the device is closed, it transitions to an opening state and attempts to establish a connection via the system service.
On success, callback.onResult is called with this HidDevice instance. On failure, callback.onError is called with one of the following: IOException: If the underlying hardware device (e.g., hidraw node) could not be accessed or the system service returned a failure; SecurityException: If the caller lacks the required permission, or the user has rejected access to the device; RemoteException: If the HID system service is unreachable.. Requires Manifest.permission.ACCESS_HID
Android reference for android.hardware.hid.HidDevice.open.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.