在Android应用程序的Java错误 [英] Java Errors in Android App

查看:287
本文介绍了在Android应用程序的Java错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个 addProximityAlert 点击信息窗口

I'm trying to to implement a addProximityAlert when an info window is clicked

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的错误,我不能确定如何解决这些问题。显然,在行公共无效addProximityAlert(双纬度,经度双){括号和逗号是没有必要的,尽管被需要他们。有人能帮忙吗?

This has "Java errors" and I'm unsure as to how to fix them. Apparently in line public void addProximityAlert(double latitude, double longitude){ the brackets and comma aren't necessary, despite them being needed. Can somebody help?

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

OK, so I've implemented some of the answers below, but I'm still having problems. The getBroadcast method is undefined for the type InfoWindowClickListener. Any suggestions?

推荐答案

尝试这样的:

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);
    }

这篇关于在Android应用程序的Java错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆