Hi,
if you have Iotivity 1.1, try the following:

        @Override
        public synchronized void
onGetCompleted(java.util.List<OcHeaderOption> headerOptionList,
OcRepresentation ocRepresentation)
        {
            Map<String, Object> values = ocRepresentation.getValues();
            for(Map.Entry<String, Object> entry: values.entrySet()) {
                String key = entry.getKey();
                Object value = entry.getValue();
            }
        }

Hope this helps!
Salvatore


On Thu, Aug 11, 2016 at 1:37 PM, EZAYEN Salim via iotivity-dev
<iotivity-dev at lists.iotivity.org> wrote:
> Hi IoTivity,
>
> I'm developing an IoTivity Client using Android, i can decover all the
> resources, but i want to discover all the attributes of each resource (GET),
> i haven' t an error, but i think that i miss something in my code,I try to
> get only the attribute of the Fan and this my code :
>
>
> @Override
> public synchronized void onResourceFound(OcResource foundResource) {
> .
> .
> .
> .
> if (resourceUri.equals("/a/collection/Fan")) {
>     mFoundCollectionResource = foundResource;
>
>     msg("Getting representation of a collection resource...");
>
>     Map<String, String> queryParams = new HashMap<>();
>     try {
>         System.out.println("test1");
>         mFoundCollectionResource.get(
>                 "",
>                 OcPlatform.DEFAULT_INTERFACE,
>                 queryParams,
>                 this
>         );
>     } catch (OcException e) {
>         Log.e(TAG, e.toString());
>         msg("Error occurred while invoking \"get\" API");
>     }
> }
>
> printLine();
> enableStartStopButton();
> .
> .
> .
>
> }
>
>
> /**
>  * An event handler to be executed whenever a "get" request completes
> successfully
>  *
>  * @param list           list of the header options
>  * @param representation representation of a resource
>  */
> @Override
> public synchronized void onGetCompleted(List<OcHeaderOption> list,
> OcRepresentation representation) {
>     msg("Representation of a light collection resource:");
>     for (OcRepresentation childRepresentation :
> representation.getChildren()) {
>         msg("\t\tURI: " + childRepresentation.getUri());
>         printLine();
>         System.out.println("seliiiiiiiim");
>     }
>     System.out.println("seliiiiiiiim2");
> }
>
> /**
>  * An event handler to be executed whenever a "get" request fails
>  *
>  * @param throwable exception
>  */
> @Override
> public synchronized void onGetFailed(Throwable throwable) {
>     if (throwable instanceof OcException) {
>         OcException ocEx = (OcException) throwable;
>         Log.e(TAG, ocEx.toString());
>         ErrorCode errCode = ocEx.getErrorCode();
>         //do something based on errorCode
>         msg("Error code: " + errCode);
>     }
>     msg("Failed to get representation of a found collection resource");
> }
>
> ////////////////////
>
>
> Can someone help me to please ?
>
>
>
>
>
>
>
> Best regards,
>
>
>
>
> Salim Zayen
> Student
> Phone :+216 23 85 66 25
>  esprit?
>
> _______________________________________________
> iotivity-dev mailing list
> iotivity-dev at lists.iotivity.org
> https://lists.iotivity.org/mailman/listinfo/iotivity-dev
>



-- 
Salvatore Iovene <salvatore.iovene at intel.com>
Linux Software Engineer
Intel Open Source Technology Center, Finland
Tel.: +358504804026

Reply via email to