OS - Android: Difference between revisions

From Phidgets Support
Line 46: Line 46:
# A jar file for directly driving USB devices from a USB port on the Android device (PhidgetsUSB.jar)
# A jar file for directly driving USB devices from a USB port on the Android device (PhidgetsUSB.jar)


To install libraries to run a Phidget remotely:
To install libraries to run a Phidget '''remotely''':
* Add libs/ and phidget21.jar to your project
* Add libs/ and phidget21.jar to your project
** In Eclipse, this can be done by selecting the menu Project → Properties → Java Build Path → Libraries (tab) → Add JAR
* Add the following to your <code>AndroidManifest.xml</code> file:
* Add the following to your <code>AndroidManifest.xml</code> file:


Line 54: Line 53:
<font size="3">
<font size="3">
<source lang=xml>
<source lang=xml>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
</source>
</source>
</font>
</font>
</div>
</div>


To install libraries to run a Phidget directly (Android 3.1 and later):
To install libraries to run a Phidget '''directly''' (Android 3.1 and later, with USB port on device):
* Add libs/, phidget21.jar, and PhidgetsUSB.jar to your project
* Add libs/, phidget21.jar, and PhidgetsUSB.jar to your project
* Add the following to your <code>AndroidManifest.xml</code> file:
<div style="background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;">
<font size="3">
<source lang=xml>
    <uses-feature android:name="android.hardware.usb.host" />
</source>
</font>
</div>
In Eclipse, jar files and library files can be added by:
Project &rarr; Properties &rarr; Java Build Path &rarr; Libraries (tab) &rarr; Add JAR


==Common Problems and Solutions==
==Common Problems and Solutions==

Revision as of 19:18, 31 October 2011

Android is a mobile OS commonly used on smartphones and tablet computers.

Recommended Languages

Android OS programs are written in Java using the Android SDK and the Phidgets library.

Installing Libraries and Drivers

Development for your Android OS Phidget application can occur on Linux, Mac OSX, or Windows.

Setup

You will need the following:

  1. The JDK and Java on your development system
  2. The Android SDK package for your development system
  3. The Eclipse plug-in for Java development
  4. The Phidget Libraries for Android
  5. For using Android to control a Phidget remotely, the Phidget Webservice should be installed on the remote computer

Step One: Install the Android SDK

Google's instructions for installing the Android SDK may be found here:

http://developer.android.com/sdk/installing.html

That link contains help and code for:

  • Installing the SDK and platform emulators
  • Connecting the SDK into Eclipse, which is useful for following the example descriptions later

Step Two: Run Google's Hello Android Application

To check that the JDK, the Android SDK, and Eclipse have all been configured correctly, use the Google HelloAndroid example:

http://developer.android.com/resources/tutorials/hello-world.html

Step Three: Install the Phidget Library

When you download and unzip the Phidget Library for Android, it will contain three things:

  1. A libs/ folder
  2. A jar file containing the general Phidget java library (phidget21.jar)
  3. A jar file for directly driving USB devices from a USB port on the Android device (PhidgetsUSB.jar)

To install libraries to run a Phidget remotely:

  • Add libs/ and phidget21.jar to your project
  • Add the following to your AndroidManifest.xml file:

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

To install libraries to run a Phidget directly (Android 3.1 and later, with USB port on device):

  • Add libs/, phidget21.jar, and PhidgetsUSB.jar to your project
  • Add the following to your AndroidManifest.xml file:

    <uses-feature android:name="android.hardware.usb.host" />

In Eclipse, jar files and library files can be added by: Project → Properties → Java Build Path → Libraries (tab) → Add JAR

Common Problems and Solutions

If you are having trouble, ensure your Phidget libraries are up to date.

  • List relevant problems from "Common Problems and workarounds" doc
  • List common problems for this OS from support forums

Limitations

Android 3.1 and later can run Phidgets directly plugged into a local USB port.

Other versions of Android can remotely control Phidgets via the Phidget Webservice. This has been tested down to Android version 2.1.