2013-03-18 85 views
-3

我试图实现一个addProximityAlert当点击的Java错误在Android应用程序

googleMap.setOnInfoWindowClickListener(
      new OnInfoWindowClickListener(){ 
       public void onInfoWindowClick(Marker marker) { 

    public void addProximityAlert(double latitude, double longitude){ 


      LatLng clickedMarkerLatLng = marker.getPosition(); 
        double lat = clickedMarkerLatLng.latitude; 
        double long1 = clickedMarkerLatLng.longitude; 

       Log.e("hello", "Output=" + lat + long1); 

        LocationManager lm; 
      // double lat=123,long1=34; //Defining Latitude & Longitude 
        float radius=30;       //Defining Radius 
      Intent intent = new Intent(PROX_ALERT_INTENT); 
      PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent, 0); 
      locationManager.addProximityAlert(
       lat, // the latitude of the central point of the alert region 
       long1, // the longitude of the central point of the alert region 
       POINT_RADIUS, // the radius of the central point of the alert region, in meters 
       PROX_ALERT_EXPIRATION, // time for this proximity alert, in milliseconds, or -1 to indicate no expiration 
       proximityIntent // will be used to generate an Intent to fire when entry to or exit from the alert region is detected 
      ); 
      IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT); 
      registerReceiver(new ProximityIntentReceiver(), filter); 
     } 
    } 

}); 

这有“Java的错误”的信息窗口,我不确定要如何解决这些问题。显然,在public void addProximityAlert(double latitude, double longitude){行中,括号和逗号不是必需的,尽管它们是需要的。有人可以帮忙吗?

编辑:好的,所以我实现了以下一些问题的答案,但我仍然有问题。该方法getBroadcast未定义该类型InfoWindowClickListener。有什么建议么?

+0

你已经在方法里面定义了错误的方法 – 2013-03-18 07:24:28

回答

0

你有两种合并方法声明:

public void onInfoWindowClick(Marker marker) { 

public void addProximityAlert(double latitude, double longitude){ 

不知道你的意图是什么,但你需要开始的addProximityAlert

+0

这个方法的意图是调用addProximityAlert方法,点击信息窗口。我还需要将解析的经度和纬度变量传递给'addProximityAlert'方法 – 2013-03-18 07:27:19

0

声明试着像在此之前,以关闭的onInfoWindowClick(Marker marker)声明:

googleMap.setOnInfoWindowClickListener(
       new OnInfoWindowClickListener(){ 
        public void onInfoWindowClick(Marker marker) { 

         addProximityAlert(latitude,longitude); 
     } 

    }); 

public void addProximityAlert(double latitude, double longitude){ 


     LatLng clickedMarkerLatLng = marker.getPosition(); 
       double lat = clickedMarkerLatLng.latitude; 
       double long1 = clickedMarkerLatLng.longitude; 

      Log.e("hello", "Output=" + lat + long1); 

       LocationManager lm; 
     // double lat=123,long1=34; //Defining Latitude & Longitude 
       float radius=30;       //Defining Radius 
     Intent intent = new Intent(PROX_ALERT_INTENT); 
     PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent, 0); 
     locationManager.addProximityAlert(
      lat, // the latitude of the central point of the alert region 
      long1, // the longitude of the central point of the alert region 
      POINT_RADIUS, // the radius of the central point of the alert region, in meters 
      PROX_ALERT_EXPIRATION, // time for this proximity alert, in milliseconds, or -1 to indicate no expiration 
      proximityIntent // will be used to generate an Intent to fire when entry to or exit from the alert region is detected 
     ); 
     IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT); 
     registerReceiver(new ProximityIntentReceiver(), filter); 
    }