1 /******************************************************************
2 * Copyright 2015 Samsung Electronics All Rights Reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 ******************************************************************/
19 package org.iotivity.service.sample.client;
21 import android.app.Activity;
22 import android.os.Bundle;
23 import android.util.Log;
24 import android.view.View;
25 import android.widget.TextView;
27 import org.iotivity.service.RcsException;
28 import org.iotivity.service.client.RcsAddress;
29 import org.iotivity.service.client.RcsDiscoveryManager;
30 import org.iotivity.service.client.RcsRemoteResourceObject;
33 * It contains the discover resource API for Discovering Container Resource
35 public class ContainerClientActivity extends Activity implements
36 RcsDiscoveryManager.OnResourceDiscoveredListener {
37 private final String LOG_TAG = "[SampleClient] "
38 + this.getClass().getSimpleName();
40 private TextView mLogView;
43 protected void onCreate(Bundle savedInstanceState) {
44 super.onCreate(savedInstanceState);
45 setContentView(R.layout.activity_container_client);
46 mLogView = (TextView) findViewById(R.id.log);
49 public void onDiscoverResourceClick(View v) {
51 RcsDiscoveryManager.getInstance().discoverResourceByType(
52 RcsAddress.multicast(), "oic.r.discomfortindex",
53 ContainerClientActivity.this);
55 } catch (RcsException e) {
61 public void onResourceDiscovered(
62 final RcsRemoteResourceObject discoveredResource) {
63 Log.i(LOG_TAG, "onResourceDiscovered");
65 runOnUiThread(new Runnable() {
68 mLogView.setText(Utils.resourceInfo(discoveredResource));
69 } catch (RcsException e) {
70 Utils.showError(ContainerClientActivity.this, LOG_TAG, e);