Android ADK Toolkit


Source link: https://github.com/palazzem/adk-toolkit

Android ADK Toolkit

This toolkit helps beginners to be up and running with ADK 2012 without difficulties. If you have any ideas to improve this toolkit, go to contribution section.

ADK toolkit exposes an AdkManager to manage UsbManager and UsbAccessory. In this way you don't need to fully understand any background concepts about how ADK works. Anyhow don't forget to read the ADK official documentation.

Support

If you need support please send a message to the Android ADK Toolkit group.

Contribution guidelines

If you want to contribute, just follow the guidelines.

Usage

Note: full documentation has more usage options. Check Usage section for more details.

Gradle dependency

This library is available on MavenCentral and JCenter (which is now the default repository used in Android) so you can add this dependency directly in your build.gradle:

dependencies {

  compile 'me.palazzetti:adktoolkit:0.3.0' 
}
 

AndroidManifest.xml

Create res/xml/usb_accessory_filter.xml configuration file to identify your accessory:

<resources>
  <usb-accessory

version="0.1.0"

model="External-Droid"

manufacturer="Example, Inc."/> </resources>

Declare in your manifest that your application requires USB accessory support:

<manifest>
  <uses-feature android:name="android.hardware.usb.accessory" android:required="true"/>

<!-- ... --> </manifest>

Then add in your activity block this ADK intent filter:

<manifest ...>
  <application ...>

<activity ...>

  <!-- ... -->

  <!-- Adk Intent Filter -->

 <intent-filter>

  <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />

 </intent-filter>

  <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"

  android:resource="@xml/usb_accessory_filter"/>

</activity>
  </application> </manifest>

Java code

To use this toolkit initialize an AdkManager in your Activity onCreate callback and then open your accessory in the onResume callback:

private AdkManager mAdkManager;  @Override protected void onCreate(Bundle savedInstanceState) {

  // ...
  mAdkManager = new AdkManager(this);
 
}
  @Override protected void onResume() {

  super.onResume();

  mAdkManager.open();
 
}

You can use the below methods to access your accessory:

// Write mAdkManager.write("Hello from Android!");
  // Read AdkMessage response = mAdkManager.read();
 System.out.println(response.getString());
 // Could outputs: "Hello from Arduino!"

Documentation

This README just provides basic information to show quickly how this library works. You can check the full documentation on Read the Docs.

Change log

0.3.0 [2015-01-10]

New features

  • Updated to latest gradle version 1.0.0
  • Added AdkMessage class, which exposes the raw byte[] array with some utility methods to get string, byte, int and float representations
  • Issue #13: refactoring AdkManager to expose a common interface for read() and write()
  • Issue #16: AdkManager constructor now accept an Activity context to initialize the accessory

Backwards incompatible changes from 0.2.x

  • removed writeSerial(String text)
  • removed writeSerial(int value)
  • removed readSerial()
  • removed readString()
  • removed readByte()

0.2.1 [2014-10-14]

  • writeSerial now accept both byte and String values
  • readSerial is now deprecated and default to readString method
  • Added readString and readByte so you can read String and byte values from the serial port

Bugfixes

  • Fixed documentation: #9

0.2.0 [2014-03-24]

  • FileInputStream and FileOutputStream are protected so they can be mocked easily during testing
  • Testing with Mockito

Bugfixes

  • Better input/output stream management to avoid NullPointerException on Accessory loading

Backwards incompatible changes in 0.2.0

  • Some class/method names are misleading so readText/sendText become readSerial/writeSerial and closeAdk/resumeAdk become close/open
  • AdkReceiver has been removed because the actual implementation of read/write can handle multiple char

0.1.0 [2014-02-05]

  • ADK fast constructor
  • Simple default implementation of Broadcast receiver and IntentFilter
  • Writing and reading features available
  • Simple AsyncTask support

Projects that use ADKToolkit

If you're interested to list your project here, feel free to submit a pull request.

License

  • Application code: FreeBSD (see LICENSE file)

Resources

A library to create two level expandable RecyclerView.

A lightweight Android activity router written in Kotlin.

Keyboard Dismisser is a simple library that allows you to dismiss keyboard by tapping anywhere outside it.

Qiscus SDK is a lightweight and powerful android chat library. Qiscus SDK will allow you to easily integrating Qiscus engine with your apps to make cool chatting application.

UniversalPreferences is simple Android library that allows you to use Shared Preferences in an easy way.

ShortRoid Library makes it easier to use different functionalities of android. Main objective is to simplify android code and make the development process faster. ShortRoid being open source encourages contributers to contribute and make it more fun for the developers to develop android apps using ShortRoid.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes