Shut down android device using Flutter application Programmatically

Viewed 33

I am making a flutter application for Android TV ( x96 mini) and I need to shut down and turn on this android device from the same flutter application. How could I implement this

I have tried Platform MethodChannel but couldn't execute

Note: I have no experience in native programming

1 Answers

I think Platform channel should work. Here is the code form this answer:

Intent requestShutdownIntent = new Intent("com.android.internal.intent.action.REQUEST_SHUTDOWN");
requestShutdownIntent.putExtra("android.intent.extra.KEY_CONFIRM", false);
requestShutdownIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(requestShutdownIntent);
Related