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.app.Activity;
26 import android.app.Fragment;
27 import android.content.Intent;
28 import android.nfc.NfcAdapter;
29 import android.os.Bundle;
30 import android.support.v4.widget.DrawerLayout;
31 import android.util.Log;
34 * SimpleBase is a sample OCF Base layer application.
35 * It can handle message and bluetooth manually.
37 public class SimpleBase extends Activity implements DrawerFragment.DrawerCallbacks {
39 private static final String TAG = "OIC_SIMPLE_BASE";
40 private DrawerFragment mDrawerFragment;
42 private CharSequence mTitle;
45 protected void onCreate(Bundle savedInstanceState) {
46 super.onCreate(savedInstanceState);
47 setContentView(R.layout.activity_simplebase);
49 mDrawerFragment = (DrawerFragment) getFragmentManager()
50 .findFragmentById(R.id.navigation_drawer);
53 mDrawerFragment.setUp(R.id.navigation_drawer,
54 (DrawerLayout) findViewById(R.id.drawer_layout));
58 public void onDrawerItemSelected(int position) {
62 mTitle = getString(R.string.title_message);
63 fragment = new MessageFragment();
66 mTitle = getString(R.string.title_bluetooth);
67 fragment = new BluetoothFragment();
70 mTitle = getString(R.string.title_cloud);
71 fragment = new CloudFragment();
74 mTitle = getString(R.string.title_keepalive);
75 fragment = new KeepAliveFragment();
78 mTitle = getString(R.string.title_template);
79 fragment = new TemplateFragment();
82 mTitle = getString(R.string.title_message);
83 fragment = new MessageFragment();
86 getFragmentManager().beginTransaction()
87 .replace(R.id.container, fragment)
90 getActionBar().setTitle(mTitle);
94 public void onNewIntent(Intent intent) {
95 super.onNewIntent(intent);
96 Log.d(TAG, "onNewIntent with changes sending broadcast IN ");
98 Intent i = new Intent();
99 i.setAction(intent.getAction());
100 i.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES,
101 intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES));
103 Log.d(TAG, "Initialize Context again resetting");