I am currently trying to build an app that will launch the maps app to the current GPS location. The user would then be able to place a marker at that location. I have a layout with a simple Place Marker
button that correctly launches the map app, but I'm not sure how to get it to zone in on the user's current GPS location. Right now I have it hard-coded to go to a certain address.
Button placeMarkerButton = (Button) findViewById(R.id.bLaunchMaps);
placeMarkerButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
String address = " 1120 N Street Sacramento, Sacramento CA 94273";
Intent maps = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address));
startActivity(maps);
} catch (Exception e) {
Log.e(TAG, e.toString());
}
}
});
Can anyone provide insight on how I might achieve this? A working example would be great since I am still fairly new to Android development.