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.
WakefulIntentServiceを使用していて、ウェイクロックを使用してdoWakefulWorkからサービスをランチしたいのですが、どうすればよいですか?(私のサービスは10秒間実行されてから、stopSelfを呼び出します)。
自分で取得するWakeLockことができますstartService()。WakeLockセカンダリサービスを呼び出す前に、必ずリリースしてくださいstopSelf()。
WakeLock
startService()
stopSelf()
10秒という短い時間で、そのコードをそれ自体に入れようとするかもしれませんWakefulIntentService。なぜ10秒なのかはわかりませんが、バックグラウンドスレッドをブロックするように調整する方が、自分のスレッドをいじるよりも簡単な場合がありますWakeLock。
WakefulIntentService