GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-sdk/android-utils at develop · AkshatAgrawal05/java-sdk

Expand file tree

/

android-utils

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

android-utils

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
example
example
 
 
library
library
 
 
releases/download
releases/download
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
settings.gradle
settings.gradle
 
 

README.md

Outline

Android SDK

Android client library to assist with using the Watson Developer Cloud services, a collection of REST APIs and SDKs that use cognitive computing to solve complex problems.

Installation

Gradle

'com.ibm.watson.developer_cloud:android-sdk:0.2.0'

AAR

Download the aar with dependencies from the Releases page.

Examples

This SDK is built for use with the java-sdk. The examples below are specific for Android as they use the Microphone and Speaker; for actual services refer to the java-sdk.

More examples here.

Microphone Input Stream

Convenience function for creating an InputStream from device microphone. You can record raw PCM data or data encoded using the ogg codec.

// record PCM data
InputStream myInputStream = new MicrophoneInputStream();

// record PCM data and encode it with the ogg codec
InputStream myOggStream = new MicrophoneInputStream(true);

An example using a Watson Developer Cloud service would look like

speechService.recognizeUsingWebSocket(new MicrophoneInputStream(),
getRecognizeOptions(), new BaseRecognizeCallback() {
  @Override
  public void onTranscription(SpeechResults speechResults){
    String text = speechResults.getResults().get(0).getAlternatives().get(0).getTranscript();
    System.out.println(text);
  }

  @Override
  public void onError(Exception e) {
  }

  @Override public void onDisconnected() {
  }

});

StreamPlayer

Provides the ability to directly play an InputStream

StreamPlayer player = new StreamPlayer();
player.playStream(yourInputStream);

CameraHelper

Provides simple camera access within an activity.

CameraHelper cameraHelper = new CameraHelper(this);
cameraHelper.dispatchTakePictureIntent();

@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CameraHelper.REQUEST_IMAGE_CAPTURE) {
      System.out.println(cameraHelper.getFile(resultCode));
    }
  }

GalleryHelper

Like the CameraHelper, but allows for selection of images already on the device.

To open the gallery:

GalleryHelper galleryHelper = new GalleryHelper(this);
galleryHelper.dispatchGalleryIntent();

@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GalleryHelper.PICK_IMAGE_REQUEST) {
      System.out.println(galleryHelper.getFile(resultCode, data));
    }
  }

Testing

Testing in this SDK is accomplished with Espresso.

To run the tests, in Android Studio:

Within the example package, right-click the androidTest/java folder and click Run 'All Tests'.

Build + Test

Use Gradle (version 2.x) to build and test the project you can use

Gradle:

$ cd android-sdk
$ gradle test # run tests
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.