问题描述
当我从应用程序中长按电源按钮时,我想关闭电源,重新启动等.该对话框与默认的android对话框相同.
我无需从我的应用程序直接调用重新启动,关机等....
只是想调用该对话框.
怎么称呼它?或如何在应用程序上发送电源按钮键?
预先感谢.
I would like to call power off,reboot, etc.. dialog as same as default android dialog when push power button long from my application.
I no need to call directly reboot,power off, etc... from my application.
Just would like to call that dialog.
How to call it ? or How to send power button key on application ?
Thanks in advance.
推荐答案
如果您查看源代码,将会看到它是在内部处理的(PhoneWindowManager.java和GlobalActions.java).通过API没有任何接口.简而言之:无法完成.
If you look at the source code, you'll see it's handled internally (PhoneWindowManager.java and GlobalActions.java). There is no interface whatsoever through the API. In short: Can't be done.
如果您具有REBOOT权限,则可以使用PowerManager.reboot()
直接重新启动电话,但是公共应用程序不太可能需要此功能.我不会信任具有REBOOT权限的应用.
If you have the REBOOT permission, you can reboot the phone directly with PowerManager.reboot()
, but it is very unlikely that a public app would need this functionality. I wouldn't trust an app with the REBOOT permission.
这篇关于如何从应用程序调用关机,重新启动对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!