2013-03-18 5 views
2

정보창을 클릭하면 마커에 근접 경고를 설정할 수있는 앱을 만들려고합니다. Android 근접 알람이 작동하지 않습니다.

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=123,long1=34; //Defining Latitude & Longitude 
       float radius=30;       //Defining Radius 

      lm=(LocationManager) getSystemService(Context.LOCATION_SERVICE); 
      Intent i= new Intent("com.example.sleepertrain5.ProximityReceiver");   //Custom Action 
      PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1, i, PendingIntent.FLAG_CANCEL_CURRENT); 
      lm.addProximityAlert(lat, long1, radius, -1, pendingIntent); 

    } 

은 위 방송 수신기는 방송 수신기

public class ProximityReceiver extends 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(); 

} 

} 

를 호출하는 코드입니다. 이 중 아무 것도 작동하지 않고 이유를 파악할 수 없습니다. 어떤 도움이라도 좋을 것입니다. 보류 의도에 대한 코드 아래

답변

0

사용 :

PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 
       nId, intent, 
       PendingIntent.FLAG_UPDATE_CURRENT); 

NID 특히 출원 의도를 나타내고있는 UNIQ 수있을 것입니다 경우.

+0

컨텍스트를 변수로 해결할 수없는 것 같습니다. –

관련 문제