• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Crash on Run

I'm developing an app that uses google maps, but for some reason it crashed every time I try to call the constructor code from the map class.


main

[HIGH]import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map cMap = new map();
}

}[/HIGH]


map

[HIGH]

import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
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.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class map extends FragmentActivity {

private GoogleMap googleMap;

public map() {

if(googleMap == null)
{
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
}

if(googleMap!= null)
{
setUpMap();
}

}

private void setUpMap()
{
googleMap.setMyLocationEnabled(true);

LocationManager locationManger = (LocationManager)getSystemService(LOCATION_SERVICE);

Criteria criteria = new Criteria();
String provider = locationManger.getBestProvider(criteria, true);
Location myLocation = locationManger.getLastKnownLocation(provider);

//Set map type
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

//Get lat and lng position
double latitude = myLocation.getLongitude();
double longitude = myLocation.getLongitude();

//Create object that holds position
LatLng latLng = new LatLng(latitude, longitude);

//Show the current location of the Map
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

//Zoom in and place Marker at Position
googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title(("HEYOOOO")));
}

}
[/HIGH]
 
logcat it

I have. I know it's something to do with the map class, because if I don't declare it, it works fine. I've tried to find the exact issue with it by using breakpoints, but the problem I have is that it doesn't reach the break points. I've set them right before the deceleration and it doesn't stop the app, it just crashes. Could it be something to do with the different extensions?
 
Back
Top Bottom