beautypg.com

Finding a daqdevice, Acquiring permission, Managing the lifecycle – Measurement Computing DAQFlex for Android Quick Start User Manual

Page 4

background image

Guidelines for developing a DAQFlex for Android project

4

This folder contains the file

device_filter.xml

, which the Android device uses to determine which USB

devices can be used by the application. An example file provides support for the USB-7202 and USB-7204 is
shown in Figure 3

Figure 3. device_filter.xml example projects

You can add any number of devices to this file to run with the software. The product IDs for each
DAQFlex-supported device are listed below.

DAQFlex device

Product ID

USB-1208FS-Plus

232

USB-1408FS-Plus

233

USB-1608FS-Plus

234

USB-7202

242

USB-7204

240

USB-2001-TC

249

USB-2408

253

USB-2408-2AO

254

USB-1608G

272

USB-1608GX

273

USB-1608GX-2AO

274

USB-201

275

USB-204

276

Guidelines for developing a DAQFlex for Android project

Finding a DAQDevice

Call the

DeviceManager

getDevices()

method to return a list of available

DaqDevices

. This list can then

be directly passed to an

ArrayAdapter

object for use in a spinner. Unlike the desktop version of DAQFlex, the

device serial number and ID is not available when running DAQFlex on an Android tablet. You must grant
permission for the device and open the device before requesting this information from the hardware.

Acquiring Permission

The Android API requires permission for every USB device. To acquire permission for the USB device, call the

DaqDevice

requestPermission()

method to open the Android USB

Permission

dialog box. The resulting

broadcast is handled in the standard way for USB devices on Android.

Refer to the example in the

DeviceSelector

class of the

ExampleShared

project.

Managing the Lifecycle

After the device has permission, but before you send any commands to the

DaqDevice

, call the

open()

method to prepare the device to receive commands.