I want to get multiple data from the ubidots using android app
Can you give more details about your question?
Are you creating an Android application and using our Java library?
Here is an example from their documentation:
http://ubidots.com/docs/devices/android.html#android-sdk
And another topic that was solved and had with a similar question
How can i cast value[] into integer value
The Value class has 3 methods:
- getTimeStamp()
- getValue()
- getContext()
You can use the getValue() method to obtain the data in that particular Value, it will return a double type.
If you want to cast the double data type to an integer data type, just do:
int newValue = (int) values[0].getValue();
Where [0] is the position of the Value you want to access.
Hi, this answer is very helpful, but I still have problem when I wrote this to get value from ubidots:
private class RecUbidots extends AsyncTask<Integer, Void, Void> { private final String API_KEY = "(my api key)"; private final String VARIABLE_ID = "(the variable id)";
@Override protected Void doInBackground(Integer... params) { ApiClient apiClient = new ApiClient(API_KEY); Variable RecVal = apiClient.getVariable(VARIABLE_ID); Value[] values = RecVal.getValues(); int Val = (int)values[0].getValue(); return null; } }
So, I have two questions.
- Why I always get the value ā0ā. Also when I changed values[0] to other data positions, I only get 0. Of course the data of my variable is not only 0)
- How can I get the newest data point of my variable?
Thanks, that helped me a lot too.