0

I need to programmatically reboot an android device, and the PowerManager's reboot functionality comes in handy.

My question is:
Should reboot be called in a separate thread or is it okay to call it in the same thread?

zx485
  • 28,498
  • 28
  • 50
  • 59
d3xter
  • 51
  • 5
  • You don't state whether or not you consulted the official documentation on that functionality; please either consult that or report back that you did so and why that did not help you. – Bane Apr 05 '18 at 16:19
  • 1
    The official documentation doesn't state anything about my question. Hence I made a stackOverflow account to ask this question. – d3xter Apr 05 '18 at 16:20
  • That's fair. My point is that SO's guidelines are that your question should reflect the research you've already done on your side prior to asking the question. – Bane Apr 05 '18 at 16:43

1 Answers1

0

While I am not an Android developer, here's what I found.

tl;dr : I haven't seen examples of calling reboot in it's own thread; have you?

Here's the official reboot docs enter image description here

Here's a SO answer on using reboot, no mention of calling it in a separate thread

Here's a 'crowd-sourced cookbook' article about using reboot; nomention of calling it in a separate thread

Guessing the API handles it gracefully automatically for you.

Bane
  • 1,772
  • 3
  • 21
  • 28
  • Yes I have seen code which has the `reboot` called in its own thread. (I can't post the link because the code isn't open-source). Since there is no logical reason I see which to prefer, I guess we could do it either way. – d3xter Apr 07 '18 at 08:46
  • Oh interesting. I agree. Personally, I'd go with simpler as long as it results in a reboot. At least later if you start getting strange behavior you'll know a possible tweak to address it. – Bane Apr 08 '18 at 17:37