0

I have problem to launch phone dialer when I click on digits inside my custom info window. This infowindow is appeared each time I click on a marker on a map api v2. This custom infowindow contains a number "567891234" highlighted.

XML layout contains:

<TextView
        android:id="@+id/dialer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:autoLink="phone"
        android:background="#ADD8E6"
        android:text="567891234" />

My activity java file:

private void setUpMap() {

    // set position, title and icon for each marker
    mMap.addMarker(new MarkerOptions().position(new LatLng(38.66, 19.789)).title("hello").snippet("test \n website: http://www.test.gr  \n this is a test message for testing purposes \n to see how big is the custom info window \n for all markers on the map").icon(BitmapDescriptorFactory.fromResource(R.drawable.location_icon)));

   // Setting a custom info window adapter for the google map
    // when a infoWindow is tapped (infoWindow open request)
        mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

            // Use default InfoWindow frame
            @Override
            public View getInfoWindow(Marker marker) {
                return null;
            }

            // Defines the contents of the InfoWindow
            @Override
            public View getInfoContents(Marker marker) {

                // Getting view from the layout file info_window_layout
                View v = getLayoutInflater().inflate(R.layout.infowindow_layout, null);

                //start phone call
                final TextView tvDialer =(TextView) v.findViewById(R.id.dialer);
                tvDialer.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View view) {
                        Intent callIntent = new Intent(Intent.ACTION_CALL);
                        callIntent.setData(Uri.parse("tel:"
                                + tvDialer.getText().toString()));
                        startActivity(callIntent);
                    }

                });
                //end phone call

                // Returning the view containing InfoWindow contents
                return v;

            }
        }); //Setting a custom info window adapter for the google map */

Permission added to androidmanifest xml file:

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Could you please tell me how to resolve this and launch dialer with my digits inserted? Besides I need to have different "number-digits" for each marker and not static text in xml layout file. How can I do this since there is no related attribute for marker except .tittle and .snippet?

Thanos Infosec
  • 57
  • 1
  • 10
  • Do you just wanna show a tel number in the `infowindow` of `marker`, and click it to dial screen? – bjiang Mar 09 '15 at 16:55
  • Also you can refer the answer [here](http://stackoverflow.com/a/15040761/4186942) to get some idea. – bjiang Mar 09 '15 at 18:33
  • Yes, I wish to show different trl number for each marker inside infowindow, and then click on it and appeared on mobile's dial screen. – Thanos Infosec Mar 10 '15 at 10:46

0 Answers0