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.
是否可以在android中以编程方式关闭显示?我想要一个按钮,按下时会关闭显示。可能吗?如果是这样,怎么做?
您可以尝试执行以下操作:
DevicePolicyManager mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); mDPM.lockNow();
这将锁定您的手机(与按下电源/锁定按钮相同)并因此转动屏幕。