Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am receiving SMS containing the data I needed such as latitude and longitude. I have successfully parse the SMS body and saved in into the database. I wanted to retrieve the stored coordinates and display it on Google Map.

What I have tried:

I am new to Android. Can you advice me what to do?
Posted
Updated 15-Mar-19 6:28am
Comments
[no name] 15-Mar-19 11:08am    
Advice on what? It says: "Ask a Question"; you say "Give me advice"!

How does one follow the other?

Here's one way to do this:
Java
// Create a Uri from an intent string. Use the result to create an Intent.
// Example latitude = 46.414382, longitude = 10.013988
Uri gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988");

// Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);

// Make the Intent explicit by setting the Google Maps package
mapIntent.setPackage("com.google.android.apps.maps");

// Attempt to start an activity that can handle the Intent
startActivity(mapIntent);

See: Google Maps Intents for Android  |  Maps URLs  |  Google Developers[^]

/ravi
 
Share this answer
 
v3
You would need to use the Google Maps SDK for Android for that, since you have gotten the latlong coordinates, you can use the Java code to render that.

Remember that you need to have a Google Maps API key for this to work, as Google's native Maps app would need you to call it from an Intent—and you do not control anything beyond that stage.

Check this page to know how to assign markers to the Google Maps: Markers  |  Maps SDK for Android  |  Google Developers[^], simplest of the code would be like,
// Code copied from the link above
private static final LatLng PERTH = new LatLng(-31.952854, 115.857342);
private static final LatLng SYDNEY = new LatLng(-33.87365, 151.20689);
private static final LatLng BRISBANE = new LatLng(-27.47093, 153.0235);

@Override
public void onMapReady(GoogleMap map) {
    mMap = map;

    // Add some markers to the map, and add a data object to each marker.
    mPerth = mMap.addMarker(new MarkerOptions()
                .position(PERTH)
                .title("Perth");
    mPerth.setTag(0);

    mSydney = mMap.addMarker(new MarkerOptions()
                .position(SYDNEY)
                .title("Sydney");
    mSydney.setTag(0);

    mBrisbane = mMap.addMarker(new MarkerOptions()
                .position(BRISBANE)
                .title("Brisbane");
    mBrisbane.setTag(0);

    // Set a listener for marker click.
    mMap.setOnMarkerClickListener(this);
}
You need to provide the position values for your own coordinates that you have in the database.

Read the complete guide for Google Maps SDK for Android here, Overview  |  Maps SDK for Android  |  Google Developers[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900