Infinity Bot
Infinity Bot

Reputation: 21

shutdown android os using flutter when press btn in android 8.1

I am developing a Flutter application and need to implement a feature that allows the app to be shutdown entire mobile. I am targeting Android 8.1, and I want to know the best approach for achieving this.

Upvotes: 0

Views: 44

Answers (1)

ThanhNguyen
ThanhNguyen

Reputation: 162

you maybe try on manifest you define:

<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />

native code, use platform channel to excute this code:

val process = Runtime.getRuntime().exec(arrayOf("su", "-c", "reboot -p"))
process.waitFor()

Upvotes: 0

Related Questions