问题的标题几乎总结了一切,我想在广播接收器中调试我的代码,但断点没有触发,我正在从 Debus As --> Android 应用程序执行我的 Android 应用程序。请帮忙!
[编辑]
这是我的广播接收器代码:
public class Alarm extends BroadcastReceiver {
@Override
public void onReceive(Context cxt, Intent intent) {
try {
Bundle bundle = intent.getExtras();
String taskName = bundle.getString("TaskName");
String taskRingTone = bundle.getString("TaskRingTone");
long endDateInMillis = bundle.getLong("EndDateInMillis");
//to disable alarm if enddate reached.
checkEndDate(cxt, (AlarmManager)cxt.getSystemService(Context.ALARM_SERVICE), endDateInMillis, pendingIntentId);
Intent reminder = new Intent(cxt, Reminder.class);
reminder.putExtra("TaskName", taskName);
reminder.putExtra("TaskRingTone", taskRingTone);
reminder.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cxt.startActivity(reminder);
} catch (Exception e) {
e.printStackTrace();
}
}
}
这是我用来在 list 中注册接收器的代码:
<receiver android:process=":remote" android:name="Alarm"></receiver>
最佳答案
为什么要在单独的进程中运行接收器?
您必须放置一些 Intent 过滤器来定义此接收者将收到的消息类型:
例如:
<receiver android:name=".Alarm">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter></receiver>
当收到 SMS 消息时,此接收器将触发。
关于java - 广播接收器中未触发断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6294665/