未决事件不会触发接收器 "onReceive"

pending itent doesn't trigger receiver "onReceive"

我在调试时执行了以下代码:

private void initPendingIntent() {
/* Retrieve a PendingIntent that will perform a broadcast */
    Intent alarmIntent = new Intent(getActivity(), AlarmReceiver.class);
    pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, alarmIntent, 0);
}

private PendingIntent pendingIntent;


private void initViews(LayoutInflater inflater, ViewGroup container) {
    rootView = inflater.inflate(R.layout.fragment_settings, container, false);

    rootView.findViewById(R.id.startAlarm).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            start();
        }
    });


public void start() {
    AlarmManager manager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
    int interval = 2000;

    manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), interval, pendingIntent);
    Toast.makeText(getActivity(), "Alarm Set", Toast.LENGTH_SHORT).show();
}

但是执行并没有在我放置在这里的断点处停止:

public class AlarmReceiver extends RoboBroadcastReceiver {

    @Override
    public void handleReceive(Context context, Intent intent) {

        // For our recurring task, we'll just display a message
        Toast.makeText(context, "I'm running", Toast.LENGTH_SHORT).show();
    }
}

和我的清单:

<receiver android:name=".boradcasts.AlarmReceiver"
          android:enabled="false">
</receiver>

<receiver android:name=".boradcasts.AlarmReceiver"
      android:enabled="false">
</receiver>

false 更改为 true =)