Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try to extend Activity rather then FragmentActivity:</p> <pre><code> public class MainActivity extends Activity implements LocationListener{ LocationManager locationManager; private GoogleMap googleMap; double lat=17.385044; double long=78.486671; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LocationManager service=(LocationManager)getSystemService(LOCATION_SERVICE); locationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); private void initilizeMap(){ if(googleMap==null){ googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap(); //check if map is created succesfully or not if(googleMap==null){ Toast.makeText(getApplicationContext(),"sorry unable to create map",1).show(); } } MarkerOptions markerOptions=new MarkerOptions().position(new LatLng(lat,long)); markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)); CameraPosition cameraPosition=new CameraPosition.Builder().target(new LatLng(17.385044, 78.486671)).zoom(12).build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); googleMap.setMyLocationEnabled(true); googleMap.setOnInfoWindowClickListener(null); } @Override protected void onResume(){ super.onResume(); initilizeMap(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload