Java 接近警报等级不为';不要发射安卓

Java 接近警报等级不为';不要发射安卓,java,android,google-maps,proximity,Java,Android,Google Maps,Proximity,我试图根据选定标记的位置设置一个接近报警,该标记的坐标存储在外部文件中,并读取到一个数组中,该数组反过来绘制坐标 googleMap.setOnInfoWindowClickListener( new OnInfoWindowClickListener(){ public void onInfoWindowClick(Marker marker) { LatLng clickedMarkerLatLng = marker.getP

我试图根据选定标记的位置设置一个接近报警,该标记的坐标存储在外部文件中,并读取到一个数组中,该数组反过来绘制坐标

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



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

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


     LocationManager lm;
    // double lat=0;
 //  double long1=0;    //Defining Latitude & Longitude
     float radius=3000;


    lm=(LocationManager) getSystemService(LOCATION_SERVICE);
    Intent i= new Intent("com.example.sleepertrain5.proximityalert");           //Custom Action
    PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), -1, i, 0);
    lm.addProximityAlert(lat, long1, radius, -1, pi);
    Toast.makeText(getBaseContext(), 
            "Info Window clicked@" + lat + "dddjdj" + long1, 
            Toast.LENGTH_SHORT).show();



    class ProximityReceiver extends android.content.BroadcastReceiver {

     @Override
     public void onReceive(Context arg0, Intent arg1) {
      // TODO Auto-generated method stub
      // The reciever gets the Context & the Intent that fired the broadcast as arg0 & agr1 

      String k=LocationManager.KEY_PROXIMITY_ENTERING;
     // Key for determining whether user is leaving or entering 

      boolean state=arg1.getBooleanExtra(k, false);
      //Gives whether the user is entering or leaving in boolean form

      if(state){
       // Call the Notification Service or anything else that you would like to do here
       Toast.makeText(arg0, "Welcome to my Area", 600).show();
      }else{
       //Other custom Notification 
       Toast.makeText(arg0, "Thank you for visiting my Area,come back again !!", 600).show();

      }

    }

    }
            }

});
}

选定标记的坐标将传递给位置管理器,但接近报警不起作用。显然,现在,它只是展示了一个祝酒词,但它甚至没有这样做。根据日志,接近接收器类从未被调用,但我不知道为什么。我尝试过不同半径的方法,但仍然不起作用。有什么想法或帮助吗?

您需要将您的BroadcastReceiver注册为您用于PendingEvent的意向操作。您可以通过添加以下行在AndroidManifest.xml中执行此操作:

<receiver android:name="MyScheduleReceiver" >
    <intent-filter>
        <action android:name="com.example.sleepertrain5.proximityalert" />
    </intent-filter>
</receiver>