Category Archives: Teaching

Pull-up Resistor

Floating

See the picture [1] below. When the switch is connected, the input pin will get the high level. But what if the switch is not connected. It is hard to tell the input pin will be read as high or low. Also the value of the input pin is very much susceptible by noise. This phenomenon is referred as floating.

Pull-up Resistor

A resistor (usually more than 10KΩ. See the picture [2] below) can guarantee that the value of the input pin is high when the switch is disconnected.

For more details, reading [2] is recommended.

Problems in updating Android SDK Tools with rev. 22

You may find an error after updating your Android SDK with Rev. 22. When you restart the ADT, you will see this error.

This Android SDK requires Android Developer Toolkit version 22.0.0 or above.
Current version is 21.x.x.
Please update ADT to the latest version.

The problem is you will not be able to update it from the “Check Updates” button. Clicking the button leads you to the “No updates were found” window along with the “Problem Occurred” window. If you ignore the problem, this error prevents us from running any of your existing projects.

This is because of the wrong URL of the Android Developer Tools Update Site. You cannot fix this problem by changing the Install/Update – Available Software Sites – Android Developer Tools Update Site since it adds automatically “content.xml” at the end of the URL.

Here is a list of steps that you need to take.

  1. Help – Install New Software in the ADT menu.
  2. Type https://dl-ssl.google.com/android/eclipse/site.xml in “Work with:” and Enter.
  3. You can see the “Developer Tools” item.
  4. Select it and click Next.
  5. Click Next one more.
  6. Click Finish accepting the terms of the license agreements.
  7. Click OK in the “Security Warning” window.
  8. Let the installer restart ADT after installing the tools.

That’s it.

GoogleMaps Demo

Here is a simple example of Android Maps v2 using MapFragment. We are assuming that the Google Play services SDK is installed. If you don’t have the SDK, please install before this. See details at here.

New Project

  • File > New > Android Application Project
    • Application Name: MapsDemo
    • Package Name: edu.kettering.mapsdemo
    • Minimum Required SDK: API 11: Android 3.0
      • Note: Fragment was introduced in API 11
    • Compile With: Google APIs (Google Inc.) (API 17)
      • If you have not installed Google APIs, Install it using the Android SKD Manager. Google APIs are the superset of Android APIs. This means “Google API level 17″ means “Android 4.2.2 (level 17) + Google APIs.”
  • Use default values for all the options.

Adding Library

Add Google Play services library.

  • Project > Properties.
  • Select Android in the left. Find the Library pane. Click “Add…” and select “google-play-services_lib”

Adding MapFragment

  • Open “activity_main.xml” and delete the text view.
  • Drag the “Fragment” in the “Layout” Palette and drop on the main layout.
    • “Choose Fragment Class” will be prompted.
    • Find “MapFragment.”
  • Align the fragment by adjusting the size. The root layout is RelativeLayout. So drag the border lines and drop at the end of the window left, top, right, and bottom.
  • Change the id to “@+id/map”
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>

Using GoogleMap class

We can get a GoogleMap object using FragmentManager. A MapFragment can be acquired from findFragmentById. The map can get from getMap().

package edu.kettering.mapsdemo;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

public class MainActivity extends Activity {
	static final LatLng ketteringLatLng = new LatLng(43.013651,-83.713498);
	private GoogleMap map;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		map = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
		map.addMarker(new MarkerOptions().position(ketteringLatLng).title("Kettering"));
		map.moveCamera(CameraUpdateFactory.newLatLngZoom(ketteringLatLng, 15));
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}

Getting an API Key

Get an API Key with the package name, “edu.kettering.mapsdemo” and the SHA-1 fingerprint. See this article for more detail.

Editing AndroidManifest.xml

We need to add permission, uses-permission, use-feature, and meta-data. “edu.kettering.mapsdemo”s in red should be replaced with your app’s package name.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="edu.kettering.mapsdemo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

    <!-- Start Maps -->
    <permission
        android:name="edu.kettering.mapsdemo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="edu.kettering.mapsdemo.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>
    <!-- End of Maps -->

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <!-- Start Maps -->
        <meta-data
      		android:name="com.google.android.maps.v2.API_KEY"
      		android:value="YOUR_OWN_KEY"/>
        <!-- End of Maps -->

        <activity
            android:name="edu.kettering.mapsdemo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Getting Ready to Use Google Maps Android API v2

Why do we need another tutorial for Google Maps Android API v2? I have discovered little things are missed or inaccurate in tutorials here and there (even in Google’s developer guideline). I do not want to repeat every single detail that you can find other places. This can be a supplementary material for Google’s developer guide for Google Maps Android API v2.

We know what the Google Maps is already. Also the 2nd version was introduced many months ago. Google Maps API in Android was also improved and named v2. Many things have  changed since last year.

Let’s get started. I am assuming we are using Eclipse as an IDE.

Install Google Play services SDK

To use Google Maps in Android we should have Google Play services. I don’t know why Google uses the name “Play” for Maps services. Anyway…

  • Start the Android SDK Manager.
  • Find Google Play services in the Extras.
  • Install the package by clicking “Install …” button.

Get the library for Google Play services

After the package is installed. We have to make the library usable for other projects.

  • Import the library so that my project can use it.
    • Go to File > Import > Android > Existing Android Code … and click Next.
    • Browse and find “<your android sdk folder>/extras/google/google_play_services/libproject/google-play-services_lib” and click Finish.
  • We just installed Google Play services library.

Make the sample app, maps work.

There are few samples in the Google Play services SDK. Let us make “maps” work. We could use this as a working template that can be utilized for future projects.

  • Import the sample.
    • Go to File > Import > Android > Existing Android Code … and click Next.
    • Browse and find “<your android sdk folder>/extras/google/google_play_services/samples/maps”.
    • The default new project name of the sample is “MainActivity.” This is not a smart choice at all. Let us change it to something more meaningful such as “MapsSample” before you click the Finish button.
    • Also make sure that you check “Copy projects into workspace” so that the original code is intact.
  • Well.. you can see tons of errors. Look hopeless. But do not worry. We will fix them shortly.
    • Go to Project > Properties.
    • Find Android in the left. You will see the Library pane in your right. If you see the ‘X’ mark in red, select it and click Remove.
    • Click Add… and select the “google-play-services_lib” item. Click OK. Now you can see the check mark in green.
  • Most errors should be gone now. RetainMapActivity has some errors that are from using “FragmentActivity.”
    • Fragment was introduced in Android 3.0 (API level 11). ADT (Build: v21.1.0-569685) makes templates using minSDK 8. The example was written using Support Lib anyway. Let us use the support library.
  • Add a support lib v4 into the project.
    • Make the “libs” folder inside the project folder. If you followed my recommendation in naming the project, the folder name is “MapsSample” and the “libs” folder must be inside the folder.
    • Find “android-support-v4.jar” at “<your android sdk folder>/extras/android/support/v4/” and copy it into the “libs” folder.
    • Go to Project > Properties.
    • Find “Java Build Path” in the left. Select the “Libraries” tab and click “Add External JARs…” Find the “android-support-v4.jar” file. Note: Do not select the jar file inside the Android SDK folder.
    • This must remove all remaining errors.
  • Run the app. You may see the program crashes.
    • Go to Project > Properties.
    • Find “Java Build Path” in the left. Select the “Libraries” tab.  Find the “android-support-v4.jar” file and remove it. I know, I know.. This is a strange step. But it should fix the crash.
  • If you still see errors from GoogleMap related packages and classes, just choose “Fix project setup..” from the Quick Fix suggestion and select “Add archive ‘google-play-services.jar – ….” and click OK. This will add “google-play-services.jar” into the build path.

Emulator

As of writing this Android emulator does not support Google Play services. We should use an actual Android device.

API Key

An API Key is required to use Google Play services.  To get a key we need an SHA-1 fingerprint and the application registration with the Google Maps Android API v2.

SHA-1 fingerprint

  • Locate debug.keysotre file in the “.android” in the current user folder.
    • /Users/<user name>/.android/ or ~/.android/
  • List the SJA-1 fingerprint.
    • keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
  • Find the “SHA1:” line in the output.
    • Alias name: androiddebugkeyCreation date: Apr 4, 2013
      Entry type: PrivateKeyEntry
      Certificate chain length: 1
      Certificate[1]:
      Owner: CN=Android Debug, O=Android, C=US
      Issuer: CN=Android Debug, O=Android, C=US
      Serial number: 515de791
      Valid from: Thu Apr 04 16:50:25 EDT 2013 until: Sat Mar 28 16:50:25 EDT 2043
      Certificate fingerprints:
       MD5: 11:22:33:44:A8:0E:99:00:33:94:44:33:55:7E:66:FD
       SHA1: FF:CC:BB:16:99:E3:AA:FF:55:44:42:77:AE:55:46:99:43:55:88:C2
       Signature algorithm name: SHA1withRSA
       Version: 3
    • Copy the hexa-decimal string after “SHA1:” (Note that the string above is not actual fingerprint)

Registration

  • Go to https://code.google.com/apis/console/
  • Select “Services” and find “Google Maps Android API v2″ in the middle of the list.
    • Turn the switch on.
  • Select API Access.
    • Click “Create new Android key…”
    • Paste the copied SHA-1 fingerprint and put ‘;’ followed by the package name (com.example.mapdemo).
  • Find “API key:” in the “Key for Android apps (with certificates)”

Put the Key into AndroidManifest.xml

Locate AndroidManifest.xml and open it. Find “YOUR_OWN_KEY” and replace it with the API key.

<application
  android:icon="@drawable/ic_launcher"
  android:label="@string/demo_title"
  android:hardwareAccelerated="true">
  <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="YOUR_OWN_KEY"/>

Connect your Android device and execute the sample. You will see “Google Maps API Demos” app.

PopupMenu Demo

The PopupMenu is anchored to a View. If a PopupMenu is shown in response to a click event to a button, the Popup will be displayed under the button if there is room.
The PopupMenu needs at least SDK 11. You need to open “AndroidManifest.xml” and change the minimum SDK version (“8″) to “11” since the ADT makes an app template with “8” for the minSdkVersion.

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

Just like any other Android API Guides, the section of the PopupMenu (http://developer.android.com/guide/topics/ui/menus.html#PopupMenu) is good for just lying-down-readers for fun but not good enough for someones who really need to use it.

Here I would like to provide a complete tutorial. But notice that this is not something that you can copy and paste it to build. You have to understand what you are doing.

First let us add a button to show a Popup menu. Please notice that the android:onClick attribute has the “showPopup” method name.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".PopupMenuDemoActivity" >

    <Button
        android:id="@+id/buttonShowMePopup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:onClick="showPopup"
        android:text="Show Me Popup" />

</RelativeLayout>

It is always good idea to use resources to maintain strings.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">PopupMenuDemo</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>
    <string name="archive">Archive</string>
    <string name="delete">Delete</string>
    <string name="popup_menu_archive_selected">Archive is selected.</string>
    <string name="popup_menu_delete_selected">Delete is selected.</string>
</resources>

A new menu XML file must be added. Add a new Android XML with “Menu” Resource Type. Use “actions.xml” as its name. Please insert two items for this demo.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@+id/archive" android:title="@string/archive"></item>
    <item android:id="@+id/delete" android:title="@string/delete"></item>
</menu>

Then we are pretty much ready to write code. For the sake of simplicity I decided to use the main activity (named PopupMenuDemoActivity) as a target of the “PopupMenu.OnMenuItemClickListener” interface. This means the activity should implement the interface. When the user selects an item, Android system will call the onMenuItemClick() callback.

package edu.kettering.popupmenudemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;
import android.widget.Toast;

public class PopupMenuDemoActivity extends Activity 
		implements PopupMenu.OnMenuItemClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_popup_menu_demo);
	}

	public void showPopup(View v)
	{
		PopupMenu popupMenu = new PopupMenu(this, v);
		popupMenu.getMenuInflater().inflate(R.menu.actions, popupMenu.getMenu());
		popupMenu.setOnMenuItemClickListener(this);
		popupMenu.show();
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.popup_menu_demo, menu);
		return true;
	}

	@Override
	public boolean onMenuItemClick(MenuItem item) {
		String msg;
		switch(item.getItemId()) {
		case R.id.archive:
			msg = getResources().getString(R.string.popup_menu_archive_selected);
			Toast.makeText(getApplicationContext(), 
                   msg, Toast.LENGTH_LONG).show(); 
			return true;
		case R.id.delete:
			msg = getResources().getString(R.string.popup_menu_delete_selected);
			Toast.makeText(getApplicationContext(), 
                    msg, Toast.LENGTH_LONG).show(); 
			return true;
		}
		return false;
	}

}

 

ProgressBar Demo

According to Android API Guides, we should avoid ProgressDialog. Instead, using ProgressBar in the layout is recommended.

Her is my layout xml. You may use other than RelativeLayout if you do not like it.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:paddingBottom="@dimen/activity_vertical_margin"
	android:paddingLeft="@dimen/activity_horizontal_margin"
	android:paddingRight="@dimen/activity_horizontal_margin"
	android:paddingTop="@dimen/activity_vertical_margin"
	tools:context=".ProgressBarDemo2Activity" >

<ProgressBar
	android:id="@+id/progressBar"
	style="?android:attr/progressBarStyleHorizontal"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:layout_alignParentLeft="true"
	android:layout_alignParentRight="true"
	android:layout_alignParentTop="true" />
</RelativeLayout>

After putting a ProgressBar into my layout, I create a Runnable object and a Thread. Call the thread with the runnable object that has my own overridden run() method.

package edu.kettering.progressbardemo2;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ProgressBar;

public class ProgressBarDemo2Activity extends Activity {
	private ProgressBar mProgressBar;
	private int mProgress = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_progress_bar_demo2);

		mProgressBar = (ProgressBar)findViewById(R.id.progressBar);

		Runnable runWork = new Runnable() {
			@Override
			public void run() {
				while(mProgress < 100) {
					mProgress = doWork();
					mProgressBar.setProgress(mProgress);
				}
			}
		};
		Thread thread = new Thread(runWork);
		thread.start();
	}

	private int doWork() {
		// sleep 50 millisecond
		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		mProgress++;

		return mProgress;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.progress_bar_demo2, menu);
		return true;
	}
}

ProgressDialog Demo

This demo shows how to use ProgressDialog in the horizontal style. You can add your own task while the progress bar is displaying. This will also show how to update the progress bar as you are doing your task. For the sake of simplicity of source code I do not create onClickListener. Instead I use the “andoroid.onClick” property of a button.

In the layout xml, add a button and change onClick property with “startProgress” that we will be implementing in a moment.

<Button
    android:id="@+id/btnStartProgress"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="startProgress"
    android:text="@string/start_progress" />

Here is the full source code.

package edu.kettering.progressbardemo;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;

public class ProgressBarDemo extends Activity {
	final static int maxValue = 500;
	private ProgressDialog progressBar;
	private int progress;
	private int progressSomthing;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_progress_bar_demo);
	}

	public void startProgress(View v) {
		progressBar = new ProgressDialog(v.getContext());
		progressBar.setCancelable(true);
		progressBar.setMessage("Wait...");
		progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
		progressBar.setProgress(0);
		progressBar.setMax(maxValue);
		progressBar.show();

		progress = 0;
		progressSomthing = 0;

		// make a runnable to be used in the thread
		Runnable runProgress = new Runnable() {
			public void run() {
				while (progress < maxValue) {

					progress = doSomething();

					progressBar.setProgress(progress);
				}

				if (progress >= maxValue) {
					progressBar.dismiss();
				}
			}
		};

		Thread thread = new Thread(runProgress);
		thread.start();
	}

	// this should return a progress value
	public int doSomething() {
		// sleep 50 millisecond
		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		progressSomthing++;

		return progressSomthing;
 	}
 }

DatePickerDialog Demo

This demo shows you how to use DatePickerDialog. You will see a warning “showDialog is deprecated” when you use “showDialog” method. First of all you could use, as of today, “showDialog” even though the message warns you. This link (http://www.technotalkative.com/android-datepickerdialog-example/) is an example that you can still use. However we do not know when it will stop working anyway since the method had been deprecated anyway.

Previously we used to use

  • showDialog(int id);
  • onCreateDialog(int id);

“showDialog” will be called in a handler of a button or something. And we need to prepare the onCreateDialog callback something like below.

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
    }
    return null;
}

Android’s API Guides say “you should use a DialogFragment as a container for your dialog.” I do not want to create a DialogFragment to use DatePickerDialog. Many recently tutorials explain how to use DialogFragment to use even simple dialogs. Here is a good news. We could use DatePickerDialog without knowing DialogFragment.

The idea of the new approach is that we create an instance of the “DatePickerDialog” class and set properties before we show the dialog by the “show” method. I think that this is a more integrated way to manage dialogs.

mDatePickerDialog = new DatePickerDialog(v.getContext(), mDateSetListener,
                                         mYear, mMonth, mDay);
mDatePickerDialog.setCancelable(true);
mDatePickerDialog.setTitle("Pick a date");
mDatePickerDialog.show();
//showDialog(DATE_DIALOG_ID);

Full source code is as below.

package edu.kettering.datepickerdemoactivity;

import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

public class DatePickerDemoActivity extends Activity {
  private TextView mDateDisplay;
  private Button mPickDate;
  private int mYear;
  private int mMonth;
  private int mDay;
  private DatePickerDialog mDatePickerDialog;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_date_picker_demo);

    // get the current date
    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);

    // get references of views
    mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
    mPickDate = (Button) findViewById(R.id.pickDate);

    // add a click listener to the button
    mPickDate.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
        mDatePickerDialog = new DatePickerDialog(v.getContext(),
                         mDateSetListener, mYear, mMonth, mDay);
        mDatePickerDialog.setCancelable(true);
        mDatePickerDialog.setTitle("Pick a date");
        mDatePickerDialog.show();
        //showDialog(DATE_DIALOG_ID);
      }
    });
    // display the current date in the TextView
    updateDisplay();
  }

  // update the date in the TextView
  private void updateDisplay() {
    mDateDisplay.setText(new StringBuilder()
             .append(mMonth + 1).append("-")
             .append(mDay).append("-")
             .append(mYear).append(" "));
  }

  // define a variable mDataSetListener
  private DatePickerDialog.OnDateSetListener mDateSetListener =
    new DatePickerDialog.OnDateSetListener() {
      public void onDateSet(DatePicker view, int year,
                            int monthOfYear, int dayOfMonth) {
        mYear = year;
        mMonth = monthOfYear;
        mDay = dayOfMonth;
        updateDisplay();
     }
   };
}

Computer Engineering Day Camp

Next week, the ECE department hosts Computer Engineering Day Camp for high school students. The program has two different sections: 1) Mobile robot, 2) Smart phone programming. But in the last day, two sections will be integrated into one to control Lego Mindstorm Robots with Smart devices through the Bluetooth technology.

I am responsible for the second section, smart phone programming. To be precise, smart device programming is better term since I am going to introduce some additional tablet devices powered by Android.

App Inventor for Android will be used for programming The block based graphical programming tool, similar to Scratch, was originally from Google Labs. Now it is maintained by MIT.

For more details such as lecture materials, you can visit here.

Test Remote Sensor

Getting temperature from remote sensor. Amarino Toolkit is used for my Android phone communicating with an Arduino board.

Follow

Get every new post delivered to your Inbox.

Join 147 other followers