Android 发送广播时无限执行

Android 发送广播时无限执行,android,Android,我想用 context.sendproadcasting意图、接收方许可 在我的申请中 但我不知道如何在函数中传递receiverPermission参数,也不知道如何在清单文件中设置 请任何人帮帮我 我想向你展示我的源代码 public class LocationReceiver extends BroadcastReceiver { public static final String BROADCAST_ACTION = "LOCATION_CHANGE"; @Overr

我想用 context.sendproadcasting意图、接收方许可

在我的申请中 但我不知道如何在函数中传递receiverPermission参数,也不知道如何在清单文件中设置 请任何人帮帮我

我想向你展示我的源代码

public class LocationReceiver extends BroadcastReceiver {
    public static final String BROADCAST_ACTION = "LOCATION_CHANGE";
    @Override
    public void onReceive(Context context, Intent intent) {
        intent.setAction(BROADCAST_ACTION);
        Bundle b = intent.getExtras();
        Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED);
        Logger.debug("Loc:"+loc);
        if(loc != null){
            doBroadCast(context,intent,loc);
        }
    }

    public void doBroadCast(final Context context,final Intent i1,final Location loc){
        Handler h = new Handler();
        h.post(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                Logger.debug("LocationReceiver->sendLocation update broadcast");
                i1.putExtra("Latitude", loc.getLatitude());
                i1.putExtra("Longitude", loc.getLongitude());
                context.sendBroadcast(i1,null);
            }
        });
    }
}
关于我写的活动

  @Override

        protected void onResume() {
            registerReceiver(broadcastReceiver, new IntentFilter(LocationReceiver.BROADCAST_ACTION));
}

    private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                UpdateUI(intent);
            }
        };

        private void UpdateUI(Intent i){
            Double Latitude = i.getDoubleExtra("Latitude",0); 
            Double Longitude = i.getDoubleExtra("Longitude",0);
            showMap(Latitude, Longitude);
        }
现在我的问题是当它发送广播时,它执行无限多广播功能,请帮我出来

intent.setActionBROADCAST\u动作后检查;动作真的被设置为广播动作 检查您是否已将此BroadcastReceiver注册为if is中的action BROADCAST_action,这就是为什么会有无限循环
1.启动第一次广播的代码是什么样子的?2.您在清单中为LocationReceiver类设置了什么意图过滤器?