デバイスの起動状態を管理する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 搭載デバイスがアイドル状態のままになると、まず画面が薄暗くなってからオフになり、最終的に CPU がオフになります。これにより、デバイスの電池が短時間で消耗するのを防ぐことができます。ただし、アプリの動作変更が必要になることもあります。
- ゲームや映画アプリなど、一部のアプリでは画面をオンのままにしておく必要があります。
- それ以外のアプリでは画面をオンのままにする必要はありませんが、重要な処理が完了するまで CPU を動作させ続けなければならない場合もあります。
以下のレッスンでは、電池の消耗を抑えつつ、必要に応じてデバイスの起動状態を維持する方法について説明します。
レッスン
- デバイスの起動状態を維持する
- 電池寿命への影響を最小限に抑えつつ、必要に応じて画面や CPU の起動状態を維持する方法について説明します。
- アラームをスケジュールする
- 反復アラームを使用して、アプリの実行期間外(デバイスがスリープ状態になっている場合も含む)に行われる処理のスケジュールを設定する方法について説明します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-08-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-27 UTC。"],[],[],null,["When an Android-powered device is left idle, it will first dim, then turn off the\nscreen, and ultimately turn off the CPU. This prevents the device\\\\'s battery\nfrom quickly getting drained. Yet there are times when your application might\nrequire a different behavior:\n\n- Apps such as games or movie apps may need to keep the screen turned on.\n- Other applications may not need the screen to remain on, but they may require the CPU to keep running until a critical operation finishes.\n\nThese lessons describe how to keep a device awake when necessary without\ndraining its battery.\n\nLessons\n\n**[Keep the device awake](/develop/background-work/background-tasks/scheduling/wakelock)**\n: Learn how to keep the screen or CPU awake as needed, while minimizing the\n impact on battery life.\n\n**[Schedule alarms](/develop/background-work/services/alarms/schedule)**\n: Learn how to use repeating alarms to schedule operations that take place\n outside of the lifetime of the application, even if the application is not\n running or the device is asleep."]]