Force
Force

Reputation: 6382

Find out if device has rebooted/crashed without BOOT_COMPLETED

I need to know if the device has crashed or rebooted and would like to avoid using a BOOT_COMPLETED permission.

Is that possible? I was thinking of reading out the uptime and compare it (how do I read it out?) Or is there a better way of doing this?

Upvotes: 0

Views: 203

Answers (1)

Victor
Victor

Reputation: 33

Reading the uptime will only help you when they have started the app "earlier" than last time (as you already know). You can read the uptime using SystemClock.elapsedRealtime() if you want to go down that path anyway.

An alternative solution, although untested, is to read:

/proc/sys/kernel/random/boot_id

This file will contain a uuid that will be different on every restart.

Upvotes: 3

Related Questions