Start-Up Guide for BIG IoT Android Consumer App Developers

Step-by-step Instructions

1. Step: Login on Marketplace

  • Select the BIG IoT Marketplace you want to use:
  • Click on Login
  • You can use your GitHub or Google account to sign in

2. Step: Create new Organization on Marketplace

  • The first time you login on the Marketplace with your account, you can create a new Organization
  • Click on New Organization (see bottom left)
  • Enter a name for your new Organization

3. Step: Create new Consumer instance

  • Click on MyConsumers
  • Click on +Consumer
  • Enter a name for your new Consumer instance (e.g. “SmartCityDashboard”)

4. Step: Find Offerings

Create a new Offering Query

  • Click on MyConsumers and select your new Consumer instance
  • Click on +OfferingQuery and give your OfferingQuery a name
  • Define a semantic Category (and if applicable also sub-categories)
  • Optionally: define a Region, a Time Period, a License, a Price, etc.
  • Save the OfferingQuery
  • Scroll down - to the bottom of your OfferingQuery. There you will see all the matching Offerings
    • NOTE: You might need to refresh your browser or reload the page to get the update
  • Explore the Offerings

5. Download Android Example Project

git clone https://github.com/BCX18ConnectedLife/big-iot.git

6. Import the Project into your IDE

  • For Android Studio IDE:
    • Go to Import project (Gradle, ...)
    • Select the Android consumer example project directory: big-iot/AndroidExampleConsumer
    • Import the project

7. Edit the Example Consumer Java application

  • Open the Example Consumer Java source file: ./app/src/main/java/android/bigiot/org/androidexampleconsumer/MainActivity.java

  • Update the CONSUMER_ID and CONSUMER_SECRET

NOTE: You can copy the Consumer ID and SECRET when you open your newly created Consumer instance on the Web Portal, and then click on Copy ID to Clipboard and Load Consumer Secret followed by Copy Secret to Clipbard (see top right).

  • Update the Offering ID here:
    consumer.subscribeByTask("... include your Offering ID here ...", this);
    

NOTE: You can copy an Offering ID when you open the Offering on the Web Portal, and then click on Copy ID to Clipboard (see top right).

8. Run the Android Example Consumer application

  • From Android Studio: Go to Run -> Run and then select your MainActivity

Developer Guide

How to develop a BIG IoT Consumer for Android?

  • A general Java developer tutorial for a Consumer can be found here
    • NOTE: The programming API for Android differs slightly from the Java example provided in this tutorial. See below for details.
  • Simple Android Consumer Example for accessing a known Offering (full example code is available here):
// Initialize Consumer with Consumer ID and marketplace URL
Consumer consumer = new Consumer(CONSUMER_ID, MARKETPLACE_URI);

// Authenticate the consumer instance 
consumer.authenticateByTask(CONSUMER_SECRET, this);
    ...
    // The authenticateByTask() method calls onAuthenticate() upon success or failure. 
    @Override
    public void onAuthenticate(String result) {
        if (result.equals(IAuthenticationHandler.AUTHENTICATION_OK)) {\
        ...
        }
    }
...

// Subscribe to Offering by OfferingId
consumer.subscribeByTask("TestOrganization-TestProvider-RandomNumberOffering", this);
    ...
    // The subscribeByTask() method calls onSubscriptionResponse() upon success or failure. 
    @Override
    public void onSubscriptionResponse(OfferingDescription offeringDescription, OfferingCore offering) {
        if (offering != null) {     
            ...
        }
    }
...

// Define Input Data as access parameters
AccessParameters accessParameters = AccessParameters.create();
       // e.g. .addRdfTypeValue("schema:latitude", 42.0).addRdfTypeValue("schema:longitude", 9.0);

// Access Offering one-time with Access Parameters (input data) --> response includes JSON results
consumer.accessByTask(this.offering, accessParameters, this);
    ...
    // The accessByTask() method calls onAccessResponse() upon success or failure. 
    @Override
    public void onAccessResponse(OfferingCore offeringCore, AccessResponse accessResponse) {
        if (accessResponse != null) {
            TextView textView = (TextView) findViewById(R.id.textView);
            textView.setText(accessResponse.getBody());
        }
    }
...

Download SDK

Information on how to download and use our SDK directly in your project is provided here.

Background Information

Background information and details on the BIG IoT architecture and vision are available here.