Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是我可以调用的任何方法,它会向我返回手机实际要关机(关机)的信息。我知道这是意图 ACTION_SHUTDOWN 但我必须从另一个来源获取有关关闭手机的信息。最好是直接形成系统。也许检查 /proc 或 /sys fs 中的相同文件。
使用 BraodcastReceiver,扩展它并覆盖onReceive.
onReceive
public class Receiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // Your code goes here } }
当你想使用它时:
activity.registerReceiver(receiver, shutDownIntent);