Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
startService() メソッドを使用してアプリを閉じた後でも、バックグラウンドで定期的に (たとえば 1 時間ごとに) 現在のデバイス時間を確認する方法は?ありがとう
取得した時間で何をしたいかによっては、必ずしもサービスが必要というわけではありません。
原則として、一定の間隔で何かを行うには、使用できますAlarmManager.setInexactRepeating()(またはsetRepeeating()、完全な周期性が本当に必要な場合)。このメソッドの を使用してPendingIntent、アラームがトリガーされたときに何でも (BroadcastReceiver、Activity、Service...) を開始します。
AlarmManager.setInexactRepeating()
setRepeeating()
PendingIntent