Launching Google Maps Directions via an intent on Android

后端 未结 15 1560
小鲜肉
小鲜肉 2020-11-22 03:46

My app needs to show Google Maps directions from A to B, but I don\'t want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this

15条回答
  •  轮回少年
    2020-11-22 04:32

    You can Launch Google Maps Directions via an intent on Android through this way

    btn_search_route.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String source = et_source.getText().toString();
                String destination = et_destination.getText().toString();
    
                if (TextUtils.isEmpty(source)) {
                    et_source.setError("Enter Soruce point");
                } else if (TextUtils.isEmpty(destination)) {
                    et_destination.setError("Enter Destination Point");
                } else {
                    String sendstring="http://maps.google.com/maps?saddr=" +
                            source +
                            "&daddr=" +
                            destination;
                    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                            Uri.parse(sendstring));
                    startActivity(intent);
                }
            }
    
        });
    

提交回复
热议问题