Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hello,
I installed android SDK, and so far, I could only modify data from the mobile application to the server.
Is it possible to first get a Thing from the server and load it in a class when defining it, for the data to be displayed in my mobile application?
Thank you
PA
Solved! Go to Solution.
Please see the Android SDK Tutorial (https://developer.thingworx.com/resources/guides/thingworx-android-sdk-tutorial).
It goes over retrieving data from the platform and storing it into variables. From there, you can easily put them into a class or use the calls to load a class directly.
It also provides the Java code you would use plus explanations! For example, using getProperty("DeliveriesMade").getValue().getValue(); to retrieve a value that you would then cast. Or using the below calls:
InfoTable result = client.readProperty(ThingworxEntityTypes.Things, ThingName, property, 10000);
// Result is returned as an InfoTable, so we must extract the value. An InfoTable
// is a collection of one or more rows. A row can have multiple fields. Each
// field has a name and a base type. In this case, the field name is 'count' and
// the base type is INTEGER, so we can use the getValue() helper.
Integer count = (Integer) result.getFirstRow().getValue(property);
// We can also access the value as a Primitive. This will work for all primitive types.
IntegerPrimitive prim = (IntegerPrimitive) result.getFirstRow().getPrimitive(property);
Please see the Android SDK Tutorial (https://developer.thingworx.com/resources/guides/thingworx-android-sdk-tutorial).
It goes over retrieving data from the platform and storing it into variables. From there, you can easily put them into a class or use the calls to load a class directly.
It also provides the Java code you would use plus explanations! For example, using getProperty("DeliveriesMade").getValue().getValue(); to retrieve a value that you would then cast. Or using the below calls:
InfoTable result = client.readProperty(ThingworxEntityTypes.Things, ThingName, property, 10000);
// Result is returned as an InfoTable, so we must extract the value. An InfoTable
// is a collection of one or more rows. A row can have multiple fields. Each
// field has a name and a base type. In this case, the field name is 'count' and
// the base type is INTEGER, so we can use the getValue() helper.
Integer count = (Integer) result.getFirstRow().getValue(property);
// We can also access the value as a Primitive. This will work for all primitive types.
IntegerPrimitive prim = (IntegerPrimitive) result.getFirstRow().getPrimitive(property);
Nice!
Thanks a lot. I could do it as you said.