New Features in Google Android 2.3

SHARE & COMMENT :

Android is the first open source software stack for mobile/handheld devices. Android predominantly provides support for building rich & flexible mobile apps. Android platform includes a compatible Linux kernel based OS, rich UI, applications, support libraries, application frameworks, support for multimedia, and more. The underlying OS components are written in C/C++ and user applications are built for Android in Java.

The Android 2.3 platform which is popularly known as Gingerbread introduces many new and electrifying features for users and game & application developers. Along with Rich user interface experience, Android adds new features for developing the mobile applications also. In this article, we will understand the Android developer features in detail.

What is Gingerbread?

To build the mobile applications easily and more dexterous, Google Android 2.3 platform comprises awesome improvements for users and developers.

New user features includes on-screen keyboard for faster input and more perceptive typing, rationalized user interface with various color schemes and lots of user interface changes for consistent and simpler usage, managing application and power to ensure background processes, memory usage and CPU time utilization along with killing the mischievous applications by using task killer, SIP Internet calling for integrating VOIP into Android platform and efficient download manager.

The following are some of the new features for developers:

  • The new video driver package: For leveraging faster3D graphics, Android works with OpenGL ES with improved performance.
  • Synchronized garbage collector: Android’s Virtual machine Dalvik launches its new concomitant garbage collector to reduce application suspensions and ensure smoother animation with augmented receptiveness in applications. The new JIT optimizations enable Dalvik code execute faster.
  • Efficient event handling: The Android platform performs well in efficiently utilizing the CPU during event handling like touch and key board events. This is very much useful in improving the responsiveness for all applications including CPU-intensive operations.
  • Native development: The Android gives the ability to make applications work with Native Development Kit to intercept inputs and sensor events for producing sound, animations, manipulating 3D graphics, access assets and storage using native code.
  • Enhanced Multimedia: Audio effects like deep boost, headphone virtualization and reverb and equalization are enhanced with local/global accessible tracks. The platform provides built-in support for video transmission and encoding. Also, it has integral support for front and rear cameras.
  • NFC support (Near Field Communications): Using NFC mechanism, applications can connect and respond to stockers, smart posters and other enabled devices.

Understanding the features of Android

1. Using video player in Android

Step 1: Creating VideoActivity to make the UI for Video View

public class VideoActivity extends Activity {
	// launching method
    @Override
    public void onCreate(Bundle state) {
		super.onCreate(state);
		//UI layout definied to load the VideoView control
		setContentView(R.layout.main);
		//getting the videoview control
        VideoView videoView = (VideoView) findViewById(R.id.VideoView);
		//defining the Media controller to control the multi media
        MediaController mc = new MediaController(this);
		//setting the videoView as anchor to mediacontroller
        mc.setAnchorView(videoView);
		//loading the the mp4 file from the Android memory
        videoView.setVideoPath("/data/h.mp4");
        videoView.setMediaController(mc);
        videoView.requestFocus();
		//starting the play
		videoView.start();
    }
}

Step 2: Define the VideoView in main.xml layout

<VideoView android:layout_height="fill_parent" android:
layout_width="fill_parent" android:id="@+id/VideoView"/>

Step 3: Pushing the video file to Android memory card from command execution adb push h.mp4 /data/h.mp4

The output of video view is as :

2. Retrieving the contacts stored in the device using Android API

Step 1: Creating ContactsView activity class to make the UI

// ContactsView is the user defined activity class
public class ContactsView extends Activity {
    /** activity is first created. */
    @Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
        // tracing the text view
		TextView cView = (TextView) findViewById(R.id.contactview);
        // creating the cursor for the contacts
		Cursor mycursor = managedQuery(ContactsContract.Contacts.CONTENT_URI, // URI
		new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME },// selection of
        // contacts
		ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" + ("1") + "'", null, ContactsContract.Contacts.DISPLAY_NAME
      + " COLLATE LOCALIZED ASC");// projection of contacts
        // displaying the contact names
		while (mycursor.moveToNext()) {
			String name = mycursor.getString(mycursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
			cView.append("Contact Name: ");
			cView.append(name);
			cView.append("\n\n");
		}
	}
}

Step 2: Define the Layout in main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical" android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<TextView android:layout_width="fill_parent"
		android:layout_height="fill_parent" android:id="@+id/contactview" />

The output is shown in the emulator screen.

3. Using Alarm service in Android platform

Step 1: Creating the SetAlarm Activity to display the interface

public class SetAlarm extends Activity {
    @Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
	public void run(View view) {
		EditText eText = (EditText) findViewById(R.id.seconds);
		int n = Integer.parseInt(eText.getText().toString());
		Intent intent = new Intent(this, Receiver.class);
	    PendingIntent pIntent = PendingIntent.getBroadcast(
		getApplicationContext(), 111, intent, 0);
		AlarmManager a = (AlarmManager) getSystemService(ALARM_SERVICE);
		a.set(AlarmManager.RTC, System.currentTimeMillis() + (n * 1000),pIntent);
		Toast.makeText(this, "Setting alarm in " + n + " seconds!", Toast.LENGTH_SHORT).show();
    }
 }

Step 2: Creating a receiver when alarm bells:

public class Receiver extends BroadcastReceiver {
    @Override
	public void onReceive(Context context, Intent intent) {
		// Vibrate the mobile phone
		Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
		vib.vibrate(3000);
		Toast.makeText(context, "Oops! Time is up!!", Toast.LENGTH_SHORT).show();
	}
}

Step 3: Creating the layout xml as below:

<EditText android:layout_width="wrap_content"
android:inputType="numberDecimal" android:layout_height="wrap_content"
android:id="@+id/seconds" android:hint="Enter no of seconds"/>
    <Button android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/yes"
    android:onClick="run" android:text="Start Alarm"/>

Step 4: Manifest xml file can be updated as below:

<application android:icon="@drawable/icon" android:label="@string/app_name" >
  <activity android:name=".SetAlarm" android:label="@string/app_name" >
     <intent-filter >
            <action android:name="android.intent.action.MAIN" / >
            <category android:name="android.intent.category.LAUNCHER" / >
            </intent-filter >
            </activity >
            <receiver android:name=".Receiver" android:enabled="true" >
            </receiver >
            </application >
     <uses-sdk android:minSdkVersion="9" / >
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>

The output is shown in the emulator screen.

After clicking the start counter, the Toast class displays the text as below:

Once the alarm bells, the following screen will be updated (with vibration on device) as below:

Conclusion

Android runs with a Linux kernel for its platform. Java programming can be used to write Android applications, those programs can run within Dalvik VM. Every Android application runs within a Dalvik VM that is residing within Linux-kernel optimized process. The basic building blocks of Android applications are activities, intents, services, and content providers. Android provides a sophisticated web browser that is based on the WebKit open source project.

Talkzilla is the coolest smartphone app for making low cost calls,Reliable, easy to use and fun : Android & iOS low cost calling app.

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*

Close
Please support the site
By clicking any of these buttons you help our site to get better