Dagvadorj Galbadrakh wrote:
> Is it possible to start Google Map centered in a specified location from
> my Activity? Heard something about geo command from Intent.

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("geo:LAT,LON")));
does it, where LAT and LON are latitude and longitude in decimal form,
negative numbers for the Southern and Western Hemispheres, respectively.

So, pulling an example from (*cough*) one of my books:

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class LaunchDemo extends Activity {
  private EditText lat;
  private EditText lon;

  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.main);

    Button btn=(Button)findViewById(R.id.map);

    lat=(EditText)findViewById(R.id.lat);
    lon=(EditText)findViewById(R.id.lon);

    btn.setOnClickListener(new View.OnClickListener() {
       public void onClick(View view) {
          String _lat=lat.getText().toString();
          String _lon=lon.getText().toString();
          Uri uri=Uri.parse("geo:"+_lat+","+_lon);
          startActivity(new Intent(Intent.ACTION_VIEW, uri));
       }
    });
  }
}

That, given a layout with two EditTexts and a Button, will launch Google
Maps on the specified coordinates.

And, yes, I probably should use StringBuilder or possibly
String.format() rather than the concatenation...

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books.html

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to