1

Please suggest me i am new in android How to Open an inbuilt Google map on button click in android i am having one image button. How to open inbuilt open google map on button click

shubham gupta
  • 27
  • 1
  • 1
  • 8

3 Answers3

7

May this helps you.

Example:-

btn_click.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Uri gmmIntentUri = Uri.parse("geo:0,0?q=");
                Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
                mapIntent.setPackage("com.google.android.apps.maps");
                startActivity(mapIntent);
            }
        }, 1000);
    }
});
Shubham Sejpal
  • 3,556
  • 2
  • 14
  • 31
3

past this code in onclick listner

String uri = "http://maps.google.com/maps?saddr=" + sourceLatitude + "," + sourceLongitude + "&daddr=" + destinationLatitude + "," + destinationLongitude;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
0

String uri = "http://maps.google.com/maps?saddr=" + sourceLatitude + "," + sourceLongitude + "&daddr=" + destinationLatitude + "," + destinationLongitude;

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));

intent.setPackage("com.google.android.apps.maps");

startActivity(intent);