I am creating a shutdown/restart function.
Intent intent = new Intent();
intent.setAction("android.intent.action.ACTION_SHUTDOWN");
sendBroadcast(intent);
In xml:
<uses-permission android:name="android.permission.SHUTDOWN"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.crazyit.net"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="android.uid.system">
But it has this error in users-permission:permission is only granted to system apps
.
Any idea?
Normal SDK applications cannot cause phones to shut down or reboot. Only applications that are part of the firmware (i.e., signed by the firmware sining key) can hold the proper permission and perform those actions.
In android SDK documents, It is clearly stated that the
ACTION_SHUTDOWN
andACTION_REBOOT
are protected intents that can only be sent by the system". You don't have the privilege to use this intent to reboot the device for security reason.As the error message explains, a normal app cannot get this permission. It would be a security risk since you could build an application that renders the phone useless.
In my case i want to launch my app on mobile switch on and set its status on mobile switched off, So for that i use in this way
and in my WifiNotification i did ::
One of the permission is ::
If your device is rooted, you can use this code for shutdown
and use this code for Reboot
I use this on Xamarin.Android