Hello experts,
I'm new to android and need some help. I'm creating a basic Mapview
application which will display my current location on the google map.
Initially i had many doubts while creating the application, but thanks
to google archives that helped me to reach this point. I
have followed almost all the threads on the google site
but still unable to see my location on the google maps. It always
shows a white screen on the emulator with google image at the bottom.
Please help to make it work. From most of the threads I learn that we
need to sign our application with the correct fingerprint. I did so
but unsuccessful.
The following will explain the steps:
1. Using sdk version android-sdk-windows-1.0_r1
2. Created a new android application.
3. Signing the application:
a. C:\Program Files\Java\jdk1.6.0_13\bin>keytool.exe -list -alias
androiddebugkey -
keystore "D:\Profiles\fknq86\Local Settings\Application Data
\Android\debug.keyst
ore" -storepass android -keypass android
b. Certificate fingerprint (MD5):
75:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:33
where XX=some alpha numeric data
c. signing up for an Android Maps API key! using link
Sign Up for the Android Maps API - Android Maps API - Google Code
4. Code below: There are 2 applications 1. Find Me 2. ShowMyLoc.
FindMe has a button which directs it to ShowMyLoc (using Intent) to
show the location on the google maps. For simplicity sake i'm pasting
the code only for ShowMyLoc app.
//ShowMyLoc.java
//Menifest.xml
I'm new to android and need some help. I'm creating a basic Mapview
application which will display my current location on the google map.
Initially i had many doubts while creating the application, but thanks
to google archives that helped me to reach this point. I
have followed almost all the threads on the google site
but still unable to see my location on the google maps. It always
shows a white screen on the emulator with google image at the bottom.
Please help to make it work. From most of the threads I learn that we
need to sign our application with the correct fingerprint. I did so
but unsuccessful.
The following will explain the steps:
1. Using sdk version android-sdk-windows-1.0_r1
2. Created a new android application.
3. Signing the application:
a. C:\Program Files\Java\jdk1.6.0_13\bin>keytool.exe -list -alias
androiddebugkey -
keystore "D:\Profiles\fknq86\Local Settings\Application Data
\Android\debug.keyst
ore" -storepass android -keypass android
b. Certificate fingerprint (MD5):
75:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:33
where XX=some alpha numeric data
c. signing up for an Android Maps API key! using link
Sign Up for the Android Maps API - Android Maps API - Google Code
4. Code below: There are 2 applications 1. Find Me 2. ShowMyLoc.
FindMe has a button which directs it to ShowMyLoc (using Intent) to
show the location on the google maps. For simplicity sake i'm pasting
the code only for ShowMyLoc app.
//ShowMyLoc.java
Code:
package org.anddev.android.findme;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class ShowMyLoc extends MapActivity {
private Location myLocation;
protected MapView myMapView = null;
protected LocationManager myLocationManager = null;
protected MapController mapController;
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
@Override
protected void onCreate(Bundle icicle) {
// TODO Auto-generated method stub
super.onCreate(icicle);
this.myMapView = new MapView(this,
"0ZFOV5MY-5tIiNoVa_UiMuiMf39w_N6T5DalZzg");
this.setContentView(myMapView);
mapController = myMapView.getController();
mapController.setZoom(15);
this.myLocation = new Location("gps");
this.myLocation.setLongitude(77.52436144125092);
this.myLocation.setLatitude(13.05096452223662);
updateView();
}
private void updateView(){
Double lat = myLocation.getLatitude();
Double lng = myLocation.getLongitude();
GeoPoint point = new GeoPoint(lat.intValue(), lng.intValue());
mapController.setCenter(point);
}
HTML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.anddev.android.findme"
android:versionCode="1"
android:versionName="1.0.0">
<uses-permission
android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" /
>
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.ACCESS_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission
android:name="android.permission.ACCESS_CELL_ID" />
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".FindMe" android:label="@string/
app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ShowMyLoc"><intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
</application>
</manifest>