简体   繁体   中英

Search nearby hospital via google map intent (Android)

I need to search nearby child hospital and find the root from button click using intent,

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
                        Uri.parse("http://maps.google.com/maps?&saddr="
                                + x
                                + ","
                                + y
                                + "&daddr=nearby child hospitals"

                                ));
                        startActivity(intent);

x,y as current lat and long.

It will show the hospitals are not in my current location(Shows different country hospitals) Then, I click back button, then click Get Directions button means (From text box contains my source lat and long, Destinations text box contains nearby child hospitals), it shows my nearer child hospitals.

Is there any way do to this in first (ie, intent call)?

You can use "geo:" URL scheme to open maps and then search nearby hospitals like this:

String uri = "geo:"+ x + "," + y +"&q=child hospitals";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));

For documentation reference, see Invoking Google Applications on Android Devices

you can use this code, intent open a map and automatic search hospital near me

String uri = "geo:"+ x + "," + y +"?q=hospitals+near+me";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
 Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + query);
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(gmmIntentUri.toString()));
        intent.setPackage("com.google.android.apps.maps");
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException ex) {
            try {
                Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(gmmIntentUri.toString()));
                context.startActivity(unrestrictedIntent);
            } catch (ActivityNotFoundException innerEx) {
                Toast.makeText(context, "Please install a maps application", Toast.LENGTH_LONG).show();
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM