Android‎ > ‎

Instant Heart Rate Bridge

Introduction

Instant Heart Rate Bridge allows your application to communicate with the Instant Heart Rate application, receiving the measured heart rate.

Installation

  1. Create a new folder called 'libs' in your project's root folder
  2. Copy AzumioInstantHeartRateBridge_V1.jar to the newly created folder
  3. Attach the JAR file to the project
    1. In Eclipse: Project -> Properties -> Java Build Path -> Add JARs...

Using the Bridge

Modifying the Manifest file

Applications does not directly access the internet but it does check if the connection is available and a minor AndroidManifest.xml file modification is required.
You need to add the following code to the root node of your Manifest file:

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

Launching the Instant Heart Rate application

// launch the Instant Heart Rate application
int error = bridge.launch(Main.this);
      
Several error codes might be returned if an error occurs:
Bridge.ErrorCodes.APPLICATION_NOT_INSTALLED indicating that the application is not installed or
Bridge.ErrorCodes.APPLICATION_NOT_UPDATED if the user has an older, unsupported application installed
Bridge.ErrorCodes.NO_INTERNET_ACCESS if there is no internet access

If everything is OK Bridge.ErrorCodes.OK is returned. 

In both cases Bridge will inform the user that he needs to install and upgrade the application and redirect him to a web page containing information about Instant Heart Rate application and an install link.

Receiving the result

After the Instant Heart Rate application has finished measuring user's heart rate it closes and returns the data. Your application receives the heart rate as a Intent extra in the onActivityResult() method

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  // extracts the heart rate from the result
  int heartRate = bridge.extractRate(requestCode, resultCode, data);
  // check if an error code was returned
  if(heartRate != Bridge.ErrorCodes.RESULT_NOT_AVALILABLE) {
  // do something with the result
    }
}

Demo application

Please, download and review the demo application attached to this document. Do not forget to attach the JAR file to the project!

Additional information

Please, do not hesitate to send us an email to info@azumio.com in case of any additional questions and we will do our best to assist.  
ċ
InstantHeartRate2IntentDemo_2015-05-11.zip
(23k)
Peter Kuhar,
May 11, 2015, 4:23 PM
Comments