如何关闭Android手机编程? [英] How to turn off Android phone programmatically?

查看:121
本文介绍了如何关闭Android手机编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个锁屏应用。当手机处于锁定模式时,它会关掉手机,而USB插入为prevent其他用户访问手机数据。有谁知道如何关闭Android设备编程,以便其他人无法访问数据,而在锁定模式的设备?

这里的code锁在锁屏界面活性home键:

  @覆盖
公共无效onAttachedToWindow()
{
    。this.getWindow()的setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
    super.onAttachedToWindow();
}
 

解决方案

这是不可能与公众的Andr​​oid SDK。

I want to make a lock screen application. When the phone is in the lock mode, it will turn off the phone while the USB is plugged for prevent other users from accessing the phone data. Does anyone know how to turn off Android devices programmatically so other people can't access the data while a device on the lock mode?

here's the code to lock the home button on the lock screen activity:

@Override
public void onAttachedToWindow()
{   
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
    super.onAttachedToWindow();  
}

解决方案

It is impossible with the public Android SDK.

这篇关于如何关闭Android手机编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆