According to 1 the code posted there can be used for Android API 12 or later. I tried the code on an emulator having API level 10 (Google API platform 2.3.3) and I get the f
i use below code hope use full to you:-
packages and extend
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class UserLocation extends FragmentActivity
code
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment mapFragment = (SupportMapFragment) fragmentManager
.findFragmentById(R.id.map);
googleMap = mapFragment.getMap();
works for me.
SupportMapFragment
http://developer.android.com/reference/com/google/android/gms/maps/SupportMapFragment.html
instead of using com.google.android.gms.maps.MapFragment
use com.google.android.gms.maps.SupportMapFragment
and for the Activity
it will have to switched to be FragmentActivity
as mentioned in the comment below
For earlier APIs, you need to use SupportmapFragment
. See the SupportMapFragment docs, Basically use class="com.google.android.gms.maps.SupportMapFragment"
instead of class="com.google.android.gms.maps.MapFragment"
{ Use this as a Reference for codes.. http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/
also in the above example one has to use his own Api Key in metadata tag of manifest instructions for generating Api key are given }
now if you want to implement this code in android 2.3
1)first change the Manifest
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
then Rightclick>Properties>Android>Android 2.3
2)there are two google play service libraries
a)..\sdk\extras\google\google_play_services_froyo\libproject\google-play-services_lib
b)..\sdk\extras\google\google_play_services\libproject\google-play-services_lib
if you'r working on android 2.3 try having the first one a as a library project (you will first need to import it as a library project File>import>................)
3)then follow instructions here
4)see to it that your Google play services app is up to date on your device