Google Maps V2 On Android Devices With Minsdk Below 11
i have problem with this line when I create project which use Google maps API v2. GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)) .getMap()
Solution 1:
Use SupportMapFragment
from a FragmentActivity
, instead of MapFragment
from an Activity
. To use fragments on devices older than API Level 11, you need to use the Android Support package's backport of fragments (where FragmentActivity
comes from).
Solution 2:
http://android-er.blogspot.de/2012/12/using-supportmapfragment.html - small example
<RelativeLayoutxmlns: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"tools:context=".MainActivity" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:text="@string/hello_world" /><fragmentandroid:id="@+id/map"android:layout_width="match_parent"android:layout_height="match_parent"class="com.google.android.gms.maps.SupportMapFragment"/></RelativeLayout>
AND:
package de.meinprospekt.android.ui;
import java.text.SimpleDateFormat;
publicclassMainActivityextendsFragmentActivity {
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Solution 3:
Fragmentfragment= getSupportFragmentManager().findFragmentById(
R.id.map);
SupportMapFragmentmapFragment= (SupportMapFragment) fragment;
GoogleMapmMap= mapFragment.getMap();
Post a Comment for "Google Maps V2 On Android Devices With Minsdk Below 11"