Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getFragmentManager with API8

I build my app with API17 as target and minSDK 12 now I have to make the app works on andorid.2.2 (API8) devices I chang the minSDK to 8 and the target SDK to 8 also I fix some errors but I don't know how to fix this

map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

(error : getFragmentManager() is undefined ) how to use google map v2
I added these to the Activity

import android.support.v4.app.* ;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentManager;

what else should I do to fix this ??

like image 706
Diaa Saada Avatar asked Jun 11 '13 10:06

Diaa Saada


2 Answers

You class must extend FragmentActivity. Make sure you have added support library.

SupportMapFragment fm = (SupportMapFragment)   getSupportFragmentManager().findFragmentById(R.id.map);
mMap = fm.getMap(); 

Also in your xml

<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

Also make sure you have imported

 import android.support.v4.app.FragmentActivity;  
 import com.google.android.gms.maps.SupportMapFragment;  
like image 81
Raghunandan Avatar answered Oct 01 '22 20:10

Raghunandan


Try using getSupportFragmentManager()

like image 32
Laurent Dezitter Avatar answered Oct 01 '22 20:10

Laurent Dezitter