Sunday, November 23, 2008

A minimal Android application to display Map, using MapView

it's a very minimal Android application using MapView to display a Map on Android Phone.

My Setup is:
Ubuntu 8.10
Eclipse 3.4.1
Android SDK 1.0

First of All, start Eclipse and create a Android Project:
In my exercise, I use AndroidMap as the name.
Project Name - AndroidMap
Package Name - com.Android.AndroidMap
Activity Name - AndroidMap
Application Name - AndroidMap



Now you have to grant permission to the application to access internet:
Select AndroidManifest.xml in res folder from Package Window on the left. Activate Permissions tab, then Add two Uses Permission, android.permission.ACCESS_COARSE_LOCATION and android.permission.INTERNET.





In order to use MapView, uses-library, "com.google.android.maps", have to be defined inside AndroidManifest.xml. Activate AndroidManifest.xml to manual edit the xml directly, insert

<uses-library android:name="com.google.android.maps" />

inside the <Application> element. The full listing of my AndroidManifest.xml:



Save and close AndroidManifest.xml.

Modify UI, (Package Window>res Folder>layout Folder>main.xml), by replacing TextView with MapView:

<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="api_key_here" />


Please note that you MUST to insert your own "api_key_here".
In order to apply your own apiKey, you have to check your Getting the MD5 Fingerprint of the SDK Debug Certificate (for emulator), and Sign Up for the Android Maps API.



Save and close main.xml.

Finally, modify AndroidMap.java:

package com.Android.AndroidMap;
import com.google.android.maps.MapActivity;
import android.os.Bundle;

public class AndroidMap extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}

@Override
protected boolean isRouteDisplayed() {
return false;
}
}



Save the java file.

Now you can Run the minimal AndroidMap on Emulator.





SORRY for all! Blogger re-format my code and make all the code mis-aligned, and not easy to read. I don't know how to fix it!!!

Sunday, November 2, 2008

Android Developers - Bonsai Blast


Jacob Abrams of Glu Mobile talks about they built their Android app, Bonsai Blast.

Sunday, September 28, 2008

The new look of Emulator of Android SDK 1

Google I/O 2008 - An Introduction to Android


An Introduction to Android
Jason Chen

Android is the Open Handset Alliance's mobile software platform. In this session, we introduce Android and discuss our vision for more open, powerful, and useful mobile devices.

Tuesday, August 26, 2008

Android 0.9 SDK beta

Updated Android 0.9 SDK beta is available to download:
http://code.google.com/android/download.html

The Andoid 0.9 SDK beta includes:

  • Extensions, changes and improvements to the framework and library APIs
  • New developer tools
  • Enhancements to existing developer tools
  • Redesigns to the home screen, some applications and UI
  • Plus various other improvements throughout the system

To take advantage of these features, you need to install the new SDK and upgrade your existing Android applications. The sections below guide you through the process.

With updated Android Emulator

http://code.google.com/android/reference/emulator.html

The Android SDK includes a mobile device emulator -- a virtual mobile device that runs on your computer. The emulator lets you prototype, develop, and test Android applications without using a physical device.

The Android emulator mimics all of the typical hardware and software features of a typical mobile device, except that it can not receive or place actual phone calls. It provides a variety of navigation and control keys, which you can "press" using your mouse or keyboard to generate events for your application. It also provides a screen in which your application is displayed, together with any other Android applications running.

To help you model and test your application, the emulator lets your application use the services of the Android platform to invoke other applications, access the network, play audio and video, store and retrieve data, notify the user, and render graphical transitions and themes.

The emulator also includes a variety of debug capabilities, such as a console from which you can log kernel output, simulate application interrupts (such as arriving SMS messages or phone calls), and simulate latency effects and dropouts on the data channel.


Saturday, February 2, 2008