Android 如何从Google map api上的标记启动活动?

Android 如何从Google map api上的标记启动活动?,android,google-maps,Android,Google Maps,我试着在谷歌上搜索,但找不到确切的解决办法。如何从地图上的标记开始另一项活动?我想单击标记并移动到另一个活动 这是我的密码 public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleMap.OnMapLongClickListener { private GoogleMap mMap; @Override protected void onCre

我试着在谷歌上搜索,但找不到确切的解决办法。如何从地图上的标记开始另一项活动?我想单击标记并移动到另一个活动

这是我的密码

public class MapsActivity extends FragmentActivity  implements OnMapReadyCallback, GoogleMap.OnMapLongClickListener {


    private GoogleMap mMap;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);

        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);

    }
    /**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */

    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        mMap.setOnMapLongClickListener(this);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.hava_durumu, menu);
        return true;
    }
    @Override
    public void onMapLongClick(LatLng point) {
        mMap.addMarker(new MarkerOptions()
                .position(point)
                .title("You are here")
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
    }
}

您可以使用setOnMarkerClickListener方法获得标记的单击

试试这个:

mMap.setOnMarkerClickListener(new OnMarkerClickListener()
                {

                    @Override
                    public boolean onMarkerClick(Marker arg0) {

                            //code for startactivity
                        return true;
                    }

                });    

访问此网站,感谢您的回答。而不是OnMapLongClick方法?或者我应该在哪里使用它?它起作用了谢谢Aakash