-2
A
回答
0
你必须使用BroadcastReceiver和AlarmManager一样。
//Create alarm manager
AlarmManager malarmMngr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
//Create pending intent & register it to your alarm notifier class
Intent intent = new Intent(this, yourBroadcastReceiver.class);
PendingIntent mPendInt = PendingIntent.getBroadcast(this, 0, intent, 0);
//set your time stamp (for once in future)
malarmMngr .set(AlarmManager.RTC_WAKEUP, yourtimestamp, mPendInt);
现在创建yourBroadcastReceiver类来调用函数。
public class yourBroadcastReceiver extends BroadcastReceiver {
public MyReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
// This method is called when this BroadcastReceiver receives an Intent broadcast.
// Call your function here
}
}
+0
难道你不想alarmManager.setExact()? – CodeCody
相关问题
- 1. 在特定时间调用Observable方法的最佳方式是什么?
- 2. 确定何时随机调用函数的最佳方法
- 3. iOS:在特定时间调用方法
- 4. 在特定时间调用方法
- 5. 在特定时间调用方法
- 6. 在特定时间调用方法
- 7. 特定时间的C#调用函数
- 8. 如何在python中用时区最佳地调整时间戳?
- 9. 获取准确时间戳的最佳方法?
- 10. 索引两个“时间戳”列的最佳方法
- 11. 特定时间后调用方法
- 12. 使用ScalaTest屏蔽动态数据(时间戳)的最佳方法
- 13. 在Sitecore的特定时间发布的最佳方式
- 14. 在特定月份之间获取行的最佳方法
- 15. 在规律的时间间隔后调用特定方法
- 16. 在特定的时间间隔后调用javascript函数
- 17. MySQL + PHP - 每次用户登录时存储时间戳的最佳方法
- 18. 时间戳使用特定的时区?
- 19. 在Android定时器中显示时间的最佳方法
- 20. 时间戳最佳实践 - PHP,MySQL的
- 21. 函数内函数最佳方法?
- 22. 用Javascript定义和调用函数的最佳方式
- 23. 在类之间调用特定方法
- 24. 如果达到一定的时间,执行函数,Python的最佳方法
- 25. 在loopback API中定义自定义函数的最佳方法
- 26. 在Swift中传递函数间索引值的最佳方法
- 27. 从python调用C函数的最佳方法?
- 28. 识别JavaScript函数调用者的最佳方法
- 29. 从Java内部调用Haskell函数的最佳方法
- 30. 确定时间戳是否在季节性工作时间内的最佳方法是什么?
您可以尝试使用警报管理器,通过此设置您可以设置特定的时间戳单个或重复出现以运行服务。 – kabuto178