我已经为 BOOT_COMPLETED 操作编写了下一个广播接收器
public class FineWeatherBootStarter extends BroadcastReceiver {
PendingIntent pendingIntent = null;
public void onReceive(Context context, Intent intent) {
long firstTime = System.currentTimeMillis();
Intent serviceIntent = new Intent(FineWeather.ACTION_REFRESH);
intent.setType(Weather.CONTENT_TYPE);
pendingIntent = PendingIntent.getService(context, 0,serviceIntent, 0);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC,
firstTime, 30*1000, pendingIntent);
Toast.makeText(context, "STARTED!!!!!!!!!", 5000).show();
}
我可以看到“STARTED!!!!!!!!!”启动设备上的消息,但我的服务似乎不是每 30 秒启动一次
哪里有问题&
最佳答案
尝试改变你的 list
<receiver android:name="MyBootReceiver" android:process=":hascode_process">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
关于android - 在 BOOT_COMPLETED 上安排任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7077456/