2 * ******************************************************************
4 * Copyright 2016 Samsung Electronics All Rights Reserved.
6 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 package org.iotivity.base.examples;
25 import android.content.Context;
26 import android.widget.Toast;
28 import org.iotivity.base.OcPlatform;
29 import org.iotivity.base.ResourceProperty;
31 import java.text.DateFormat;
32 import java.util.Calendar;
33 import java.util.Date;
34 import java.util.EnumSet;
35 import java.util.Locale;
38 * This class charge of common part.
42 public static final int DATA_SIZE = 3000;
43 public static final String COAP_TCP = "coap+tcp://";
44 public static String TCP_ADDRESS = "192.168.0.1";
45 public static final String TCP_PORT = ":8000";
46 public static final String IP_ADDRESS = "0.0.0.0";
47 public static final int IP_PORT = 0;
48 public static final String GET_COMMAND = "get_command";
49 public static final String STATE_KEY = "state_key";
50 public static final String STATE_GET = "state_get";
51 public static final String LARGE_KEY = "large_key";
52 public static final String LARGE_GET = "large_get";
53 public static final String RESOURCE_URI = "/a/light";
54 public static final String RESOURCE_TYPE = "core.light";
55 public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;
56 public static final EnumSet<ResourceProperty> RESOURCE_PROPERTIES =
57 EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE);
59 public static String getDateCurrentTimeZone() {
60 StringBuilder sb = new StringBuilder();
62 Calendar calendar = Calendar.getInstance();
63 calendar.setTimeInMillis(System.currentTimeMillis());
64 DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
67 Date currentTimeZone = calendar.getTime();
68 sb.append(dateFormat.format(currentTimeZone));
69 } catch (Exception e) {
75 public static void showToast(Context context, String msg) {
76 Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();