I'm trying to modify or override the functionality of power off menu button in android (not the button to screen on / off).
I want to fired a process before the device shutdown, run a process and after that shutdown the device
If this it's possible?
Yes it is possible.You don't have to have a rooted device just use a broadcast. In manifest:
<receiver android:name="com.example.broadcastreceiver.YourClass">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
</intent-filter>
</receiver>
YourClass:
public class YourClass extends BroadcastReceiver {
@Override
public void onReceive(Context c, Intent i) {
if(i.getAction().equals("android.intent.action.ACTION_SHUTDOWN")){
//Fire your code here
}
}};
}
If it sounds impossible,Find another way to do the same thing ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.