我一直试图通过程序锁定设备.但我还是找不到解决方案.我想通过程序锁定Android froyo2.2.我尝试过keyguardmanager和DeviceAdminManager.
我的应用是远程锁定设备.收到带有某些代码字的消息后,它会锁定电话.我发现很多Api_demo程序作为解决方案,但我不能单独提取锁定代码并找到解决方案.
我想在我的应用程序中实现屏幕锁定功能,但目前我无法让它工作.我有一个alertDialog,它将通过使用几个按钮请求用户输入.如果用户按"否",我想锁定屏幕(无限期,不是一段时间).以编程方式锁定屏幕的最佳方法是什么?我尝试过使用以下内容,但是,虽然我的对话框被取消,但屏幕永远不会锁定.
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.reenableKeyguard();
Run Code Online (Sandbox Code Playgroud)
mycode的
import android.app.Activity;
import android.app.AlertDialog;
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Window;
public class MyApp extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
this.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
startDialog();
}
private void startDialog() {
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
myAlertDialog.setMessage("Do you want to exit the application?");
myAlertDialog.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int …Run Code Online (Sandbox Code Playgroud) 我正在使用Unity构建一个Android应用程序,它正在顺利进行.但是,我有一个奇怪的问题,有关屏幕超时和锁屏没有显示.
应该发生什么
怎么了
笔记
我怀疑这是由于在屏幕超时时Unity不放弃的唤醒锁定引起的.这会导致应用程序保持焦点,锁屏永远不会"加载".这是一个非常严重的问题.
有谁知道有任何方法来解决这个问题?
注意:我已经在一周前的Unity Answers上问过这个问题,但还没有得到任何回复.我想也许我在这里有更好的运气.