快速唤醒USB调试连接中的android机
2015-03-13 16:16
686 查看
如果调试过程中有一段时间没有操作android机,那么它会自动关闭屏幕。这时需要按一下电源按钮才能唤醒。
怎样才能去掉这个烦人的按下电源按钮的操作呢?
经过搜索与尝试,发现了下面的方案:
“利用adb shell am start命令启动一个能点亮屏幕的app。”
1. 构造app
这个能强制点亮屏幕的app使用了PowerManager的 ACQUIRE_CAUSES_WAKEUP标记。
api reference对该标记的说明:“Normal wake locks don't actually turn on the illumination. Instead, they cause the illumination to remain on once it turns on (e.g. from user activity). This flag will force the screen and/or keyboard to
turn on immediately, when the WakeLock is acquired. A typical use would be for notifications which are important for the user to see immediately.”
关键代码如下:
点亮屏幕后app即可退出了。
2. 添加外部工具按钮
在Eclipse IDE的外部工具按钮上进行配置,执行adb命令:
adb shell am start -n com.hoxily.wakeup/.MainActivity
如图所示
参考文档
把外部工具和构建器集成到 Eclipse 中,http://www.ibm.com/developerworks/cn/education/opensource/os-eclipse-tools/index.html
http://developer.android.com
附件
Wakeup.apk, http://pan.baidu.com/s/1ntE9PlJ
Wakeup-src.zip,http://pan.baidu.com/s/1dD2ETo9
怎样才能去掉这个烦人的按下电源按钮的操作呢?
经过搜索与尝试,发现了下面的方案:
“利用adb shell am start命令启动一个能点亮屏幕的app。”
1. 构造app
这个能强制点亮屏幕的app使用了PowerManager的 ACQUIRE_CAUSES_WAKEUP标记。
api reference对该标记的说明:“Normal wake locks don't actually turn on the illumination. Instead, they cause the illumination to remain on once it turns on (e.g. from user activity). This flag will force the screen and/or keyboard to
turn on immediately, when the WakeLock is acquired. A typical use would be for notifications which are important for the user to see immediately.”
关键代码如下:
powerManager = (PowerManager)this.getSystemService(Context.POWER_SERVICE); @SuppressWarnings("deprecation") int levelAndFlags = PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK; wakeLock = powerManager.newWakeLock(levelAndFlags, "com.hoxily.wakeup"); wakeLock.acquire(5000);
点亮屏幕后app即可退出了。
2. 添加外部工具按钮
在Eclipse IDE的外部工具按钮上进行配置,执行adb命令:
adb shell am start -n com.hoxily.wakeup/.MainActivity
如图所示
参考文档
把外部工具和构建器集成到 Eclipse 中,http://www.ibm.com/developerworks/cn/education/opensource/os-eclipse-tools/index.html
http://developer.android.com
附件
Wakeup.apk, http://pan.baidu.com/s/1ntE9PlJ
Wakeup-src.zip,http://pan.baidu.com/s/1dD2ETo9
相关文章推荐
- android pc通过wifi调试手机(无需USB连接)
- 默认开启USB连接调试
- iOS逆向工程使用LLDB的USB连接调试第三方App
- Ubuntu下使用adb和USB连接的方式进行android设备调试
- Delphi 调试连接 任意Android手机/平板/盒子(要安装Google USB Driver,并且还有USB的相关许多文章)
- Fedora 14以USB调试方式连接手机(HTC G1) 转载
- 在linux中配置usb连接(android手机调试)
- 刷了MIUI的手机在OSX下连接USB调试的方法
- 互联网远程唤醒android车机(车机连接USB 4G模块)的实现
- 使用adb无线连接手机进行开发和调试,适用于usb host/accessory设备调试
- 没有数据线,Wifi也能连接Android真机开发调试!彻底解决“无法识别的USB设备”等数据线连接问题!
- Ubuntu杂记——Ubuntu下以USB方式连接Android手机调试
- Android_ADB_wifi连接调试同时连接usb
- 在Ubuntu中USB连接手机调试
- android开发-wifi连接eclipse调试,拜拜USB
- 通过USB连接到Android真机,在终端中配置adb工具,并使用adb工具对安卓手机进行调试
- lg g2-D802在线升级官方5.0rom后打开usb调试后连接不上电脑上助手等原因
- 使用adb和USB连接的方式进行android设备调试
- B4A 或其它Android开发平台连接USB设备进行调试
- 电脑连接手机的软件初次使用,USB调试和驱动很重要