gpt4 book ai didi

Android:IntentService 启动但 onHandleIntent 未执行

转载 作者:行者123 更新时间:2023-11-30 01:03:54 25 4
gpt4 key购买 nike

<分区>

我希望 IntentService 每 10 秒运行一次,并放置一个简单的调试行。这是我的代码:

在 list 中:

<service android:name="com.test.test.TheService" />

创建警报管理器以每 10 秒调用一次服务

am.setRepeating(AlarmManager.RTC_WAKEUP,
cal.getTimeInMillis(),
10000,
servicePendingIntent);

服务本身

public class TheService extends IntentService {

public static int SERVICE_ID = 1;

public TheService() {
super("TheService");
}

@Override
protected void onHandleIntent(Intent intent) {
Log.d("service","I'm in on Handle Intent");
}
}

在模拟器的监视器中,我每 10 秒就会看到这条线

1270-1297/system_process I/ActivityManager: START u0 {flg=0x4 cmp=com.test.test/.TheService (has extras)} from pid -1

尽管它写着“有额外的”,但我实际上没有添加任何额外的。一般来说,它看起来很好,但调试永远不会打印出来,调试代码上的断点永远不会停止,就好像服务每 10 秒启动一次,但它什么也不做。

我错过了什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com