Android模拟器可以接收ACTION_POWER_CONNECTED意图? [英] Can the Android emulator receive ACTION_POWER_CONNECTED intents?

查看:283
本文介绍了Android模拟器可以接收ACTION_POWER_CONNECTED意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的申请,我想监听像这样的ACTION_POWER_CONNECTED意图:

in my application, I'm trying to listen for the ACTION_POWER_CONNECTED intent like so:

    <service android:name=".myService">
        <intent-filter>
            <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
        </intent-filter>
    </service>

我认为我将能够通过通过telnet发送模拟器权力交流的命令来测试这一点,但是,我的服务似乎并不被接受的意图。我能够用这个方法蛮好收到BATTERY_LOW意图。

I assumed I would be able to test this by sending the emulator the "power ac on" command over telnet, however, my service doesn't seem to be receiving the intent. I'm able to receive the BATTERY_LOW intent using this method just fine.

我注意到这条消息: http://groups.google.com/group / Android的开发者/邮件/ 84e968734c51d50e 暗示你不能用模拟器测试,但它的一个几个月大,并在它的链接似乎是外的日期,我没有方便的设备进行测试。

I notice this message: http://groups.google.com/group/android-developers/msg/84e968734c51d50e suggests that you can't test this with the emulator, but its a few months old and the link in it seems to be out-of-date, and I don't have a device handy to test.

谁能证实?你能接收使用命令从远程登录这个意图是什么?谢谢你。

Can anyone confirm? Are you able to receive this intent using a command from telnet? Thanks.

推荐答案

我可以证实这一点。你可以得到一个广播接收器电源连接的事件。

I was able to confirm this. You can get the Power Connected event with a broadcast receiver.

    <receiver android:name=".MyReceiver" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
                <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

从远程登录命令是:

The command from telnet would be:

    power ac on

这篇关于Android模拟器可以接收ACTION_POWER_CONNECTED意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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