2013-03-18 133 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); 
    }