如何在 Android 2.1 中删除模拟器启动到主屏幕后出现的锁定屏幕

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2833488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:33:16  来源:igfitidea点击:

How to remove the lock screen that appears after the emulator boots up to main screen in Android 2.1

android

提问by user341053

The lock screen appears at the main screen, after the emulator boots up. I want to disable locking at main screen, so that the next time I boot up my emulator the lock screen will not appear. Can anybody suggest the best solution for this?

模拟器启动后,锁定屏幕出现在主屏幕上。我想在主屏幕上禁用锁定,以便下次启动模拟器时不会出现锁定屏幕。有人可以为此提出最佳解决方案吗?

回答by gorbysbm

The latest version of the Android OS 4.2.2 has a way to remove it via the emulator Settings. Just go to : Security >> Screen Lock, and select "NONE." Make sure you are saving the emulator settings to Snapshot so you don't have to keep going through these same steps.

最新版本的 Android OS 4.2.2 可以通过模拟器设置将其删除。只需转到:安全>>屏幕锁定,然后选择“无”。确保将模拟器设置保存到 Snapshot,这样您就不必继续执行这些相同的步骤。

回答by Colin Devon

I just suffered this issue as well (not sure if it could be solved programatically) and found that hitting page up worked for me.

我也遇到了这个问题(不确定是否可以通过编程方式解决)并发现点击翻页对我有用。

http://forum.archosfans.com/viewtopic.php?f=34&t=30574

http://forum.archosfans.com/viewtopic.php?f=34&t=30574

回答by zhen01.wang

The lock screen is started by a service.The service is WindowManagerService.In the service ,the code "wm.systemReady()" starts the Lock sceen.

锁屏是由一个服务启动的。该服务是WindowManagerService。在服务中,代码“wm.systemReady()”启动了锁屏。

回答by Jeff Axelrod

From this answer:

从这个答案

  1. If you are the developer or have access to the code of the application under test then the best and the easiest way of achieving this is using: http://developer.android.com/guide/topics/testing/activity_testing.html

     KeyguardLock keyguardLock = ((KeyguardManager)keyguardService).newKeyguardLock(TAG);
    
     if (enable) {
        keyguardLock.reenableKeyguard();
     } else {
        keyguardLock.disableKeyguard();
     }
        return true;
     }
    

    In my opinion this is a nasty solution as it requires you to include an extra permission in your application -- one that virtually no application will need.

    As [OP] mentioned, you should remove this, but people forget: I've seen a few apps released on the Market that still have this permission included, when it really should have been removed.

    If you can automaticallyonly include this permission for test builds, or automatically remove the permission when doing a release build, then fine.

  2. Second best method is to use adb shell commands to unlock it at boot of the emulator. The actual code would differ depending upon what method you use to call these commands. This of course has the limitation that it can be run only at the first start up of the emulator, once the emulator has started this command would do nothing.

    You can run the "adb shell" command as often as you like. On the first startup, it will open the Android menu, which should be harmless. On each subsequent startup, it will press Menu, which will unlock the screen, as desired.

  3. Third method is telnet into the emulator and then use the EV_KEY to unlock it.

    telnet localhost 5554 event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0 quit

    You can put this in a bat or shell file and call it from your test to unlock the Home screen. This again has the limitation of being able to unlock at only the first boot and cannot be used to unlock the Home screen after the first boot.

    This seems backwards. The home screen is not locked when you start an emulator for the first time.

    In any case, I wouldn't recommend this at all, since we have the more reliable "adb shell" solution above. Which also should work on real devices.

  4. Fourth option is to use maven to unlock it. http://issues.hudson-ci.org/browse/HUDSON-7185This is very useful for CI purposes but is limited by inability to unlock the screen from eclipse. So if you are writing your tests in Eclipse you have to run the tests using command prompt if you need to unlock the screen.

    Clarification: that bug report is about the Android Emulator plugin for Jenkins/Hudson, and not Maven. The Maven solution mentioned there just uses the "telnet" option above.

  5. Finally, a further option is to use Android emulator snapshots. Introduced in Android SDK Tools v9, the emulator now supports saving the current state of the emulator (similar to other virtualisation products like VMware).

    So you could start the emulator once, so that it becomes unlocked, then shut it down. Starting the emulator subsequently will immediately load up a clean emulator with the screen unlocked (so long as you do not save emulator state at shutdown (i.e. the "--no-snapshot-save" option).

    BTW, this snapshot functionality will be automated and included in the next release of the Android Emulator Plugin for Jenkins/Hudson.

  1. 如果您是开发人员或有权访问被测应用程序的代码,那么最好和最简单的方法是使用:http: //developer.android.com/guide/topics/testing/activity_testing.html

     KeyguardLock keyguardLock = ((KeyguardManager)keyguardService).newKeyguardLock(TAG);
    
     if (enable) {
        keyguardLock.reenableKeyguard();
     } else {
        keyguardLock.disableKeyguard();
     }
        return true;
     }
    

    在我看来,这是一个令人讨厌的解决方案,因为它要求您在应用程序中包含一个额外的权限——几乎没有应用程序需要这个权限。

    正如 [OP] 所提到的,您应该删除它,但人们忘记了:我已经看到市场上发布的一些应用程序仍然包含此权限,但实际上应该将其删除。

    如果您可以自动只为测试构建包含此权限,或者在进行发布构建时自动删除该权限,那么很好。

  2. 第二种最好的方法是使用 adb shell 命令在模拟器启动时解锁它。实际代码会因您调用这些命令所使用的方法而异。这当然有一个限制,它只能在模拟器第一次启动时运行,一旦模拟器启动,这个命令就什么都不做。

    您可以根据需要随时运行“adb shell”命令。在第一次启动时,它会打开Android菜单,这应该是无害的。在随后的每次启动时,它将按菜单键,这将根据需要解锁屏幕。

  3. 第三种方法是 telnet 进入模拟器,然后使用 EV_KEY 解锁它。

    telnet localhost 5554 事件发送 EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0 退出

    你可以把它放在一个 bat 或 shell 文件中,并从你的测试中调用它来解锁主屏幕。这再次具有只能在第一次启动时解锁的限制,并且不能在第一次启动后用于解锁主屏幕。

    这似乎倒退了。首次启动模拟器时,主屏幕未锁定。

    无论如何,我根本不推荐这样做,因为我们有上面更可靠的“adb shell”解决方案。这也应该适用于真实设备。

  4. 第四个选项是使用 maven 来解锁它。 http://issues.hudson-ci.org/browse/HUDSON-7185这对于 CI 目的非常有用,但受限于无法从 eclipse 解锁屏幕。因此,如果您在 Eclipse 中编写测试,并且需要解锁屏幕,则必须使用命令提示符运行测试。

    澄清:该错误报告是关于 Jenkins/Hudson 的 Android Emulator 插件,而不是 Maven。那里提到的 Maven 解决方案只使用上面的“telnet”选项。

  5. 最后,另一种选择是使用 Android 模拟器快照。模拟器在 Android SDK Tools v9 中引入,现在支持保存模拟器的当前状态(类似于其他虚拟化产品,如 VMware)。

    因此,您可以启动模拟器一次,使其解锁,然后将其关闭。随后启动模拟器将立即加载一个干净的模拟器,屏幕解锁(只要您在关机时不保存模拟器状态(即“--no-snapshot-save”选项)。

    顺便说一句,此快照功能将自动化并包含在下一版本的 Jenkins/Hudson 的 Android 模拟器插件中。

回答by Gaurav Vaish

AFAIK, you can't unless you create your own home screen.

AFAIK,除非您创建自己的主屏幕,否则您不能这样做。

回答by Chathz

Following steps worked for me.

以下步骤对我有用。

Steps: Go to AVD Manager -> Right click on the Virtual Device -> Wipe Data

步骤:转到 AVD 管理器 -> 右键单击​​虚拟设备 -> 擦除数据

回答by Murat Murat

enter image description here

在此处输入图片说明

  1. Andy (Right Click) - Settings - VMI Import Tool
  2. Andy (Right Click) - Andy VM Launcher - Delete This Andy - New Andy - Launch
  1. Andy(右键单击)-设置-VMI 导入工具
  2. Andy(右键单击) - Andy VM Launcher - 删除这个 Andy - New Andy - Launch