Giter Site home page Giter Site logo

devicehive-android's Introduction

DeviceHive Android Example

DeviceHive Android Example demostrates the usage of DeviceHive Java Library inside Android Application. DeviceHive Java Library could be easily implemented into any Android Project. It supports Android Applications for tablets and phones, Android Wear and Android Things.

This Android Application is showing how easily you can register a new Device or get the existing and start sending any data to the server. For an example we are sending current Location.

//Creating DeviceHive Instance
  DeviceHive deviceHive = DeviceHive.getInstance().init(String serverUrl,
                    new TokenAuth(String refreshToken));
//Registering new Device or getting the existing
  DHResponse<Device> dhResponse = deviceHive.getDevice(String deviceId);
        if (dhResponse.isSuccessful()) {
            Device device = dhResponse.getData();        
        }
//Sending of the notifications
device.sendNotification(String notificationName, List<Parameter> params);

DeviceHive license

DeviceHive is developed by DataArt Apps and distributed under Open Source Apache 2.0. This basically means you can do whatever you want with the software as long as the copyright notice is included. This also means you don't have to contribute the end product or modified sources back to Open Source, but if you feel like sharing, you are highly encouraged to do so!

© Copyright 2017 DataArt Apps © All Rights Reserved

devicehive-android's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

devicehive-android's Issues

GetDeviceEquipmentStateCommand - bug when getting deviceId

When trying to get deviceId from with

GetDeviceEquipmentStateCommand.getDeviceId(resultBundle), an error is returned that states that expected result was String, but it got Parcelable instead.

The simple fix is to make a change in the following line:

GetDeviceEquipmentStateCommand: 96

from getParcelable(...) to get String().

Unhandled status code 204 and unhandled exception - bug ?

I think I found a bug when device is trying to register.
When device registers returns status code 204, from documentation for RESTful protocol 1.3.1 -
"204 No Content: Requested operation completed successfully and there is no resource in the response body (typically for DELETE operations)."
So according to this i think that code 204 is successful status code and need to be in isSuccessStatusCode(int statusCode) in network/NetworkCommand.java. So on line 171

FROM:
protected boolean isSuccessStatusCode(int statusCode) {
return statusCode == 200 || statusCode == 201;
}

TO:
protected boolean isSuccessStatusCode(int statusCode) {
return statusCode == 200 || statusCode == 201 || statusCode == 204;
}

When the code is 204 and it has no resources in the body, an exception is raised, because responce.getEntity() returns null and toString cannot parse it. So on line 209 I suggest

FROM:
String responceString = EntityUtils.toString(responce.getEntity());

TO:
try {
responceString = EntityUtils.toString(responce.getEntity());
} catch (IllegalArgumentException iae) {
responceString = "";
}

Please look at this bug, and if it is real bug please fix it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.