如何在android中的特定时间在后台每天一次在sqlite中插入数据?
我的任务是每天10:00在后台根据某些条件在sqlite中插入或更新某些特定数据。我被卡住了。请帮忙 Make如何在android中的特定时间在后台每天一次在sqlite中插入数据?,android,android-studio,android-service,alarmmanager,Android,Android Studio,Android Service,Alarmmanager,我的任务是每天10:00在后台根据某些条件在sqlite中插入或更新某些特定数据。我被卡住了。请帮忙 MakeYourReceiver.java文件 class YourReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().matches(Intent.ACTION_
YourReceiver.java
文件
class YourReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().matches(Intent.ACTION_TIME_TICK)) {
if (check_your_time_with_system_time) {
// update your DB here
}
}
}
}
在manifest.xml中注册您的接收者
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.TIME_TICK"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
YourReceiver
的onReceive()
方法每分钟都会被调用。没有任何代码如何帮助您..如何开发一个在一天一次的特定时间在后台运行的服务..这将解决我的问题。这应该对你有帮助