如何发送android系统intent?

发布于 2024-11-18 01:30:13 字数 787 浏览 2 评论 0原文

由于此处描述的错误,我想编写一个小android应用程序以间接的方式解决问题。

我想编写一个程序,以编程方式断开和重新连接充电器。

我是 java 和 android 应用程序的新手(尽管我非常了解 c、c++、C#)。

从这里开始,我不确定我是否走在正确的道路上,所以我很高兴听到另一个解决方案。 我想出的方法是发送一个名为 BATTERY_CHANGED 的意图,如此处< /a>.

我引用:“这是一个受保护的意图,只能由系统发送。”

我想发送它,这样电池的充电状态就会改变(当然,当电池充满时) 我无法“触摸”这个方法,IDE(eclipse,带sdk,带ADT插件,在win 7 x64上)无法将android.intent.action.BATTERY_CHANGED识别为现有值。 我认为另外两件事可能有用: developer.android.com/reference/android/content/Intent.html#ACTION_POWER_CONNECTED developer.android.com/reference/android/content/Intent.html#ACTION_POWER_DISCONNECTED

Because of the bug described here i want to write a little android app to fix the problem in an indirect approach.

I want to write a program that disconnect and reconnect the charger programmatically.

I am new to java and to android applications ( although i know very well c,c++,C#).

from here i am not sure i am on the right way, so i will be happy to hear another solution.
the one i came up with is to send an intent called BATTERY_CHANGED as described here.

i quote: "This is a protected intent that can only be sent by the system."

I want to send it so the battery state of charging will change (of course, when battery is full)
i couldn't "touch" this method, the IDE(eclipse,with sdk, with ADT plugin, on win 7 x64) could not recognize the android.intent.action.BATTERY_CHANGED as an existing value.
another two things i thought might be useful:
developer.android.com/reference/android/content/Intent.html#ACTION_POWER_CONNECTED
developer.android.com/reference/android/content/Intent.html#ACTION_POWER_DISCONNECTED

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光暖心i 2024-11-25 01:30:13

发送 ACTION_BATTERY_CHANGED 不会影响充电,即使您可以自己广播它(只有固件可以做到)。

Sending ACTION_BATTERY_CHANGED will not affect the charging, even if you could broadcast it yourself, which only the firmware can do.

夏日浅笑〃 2024-11-25 01:30:13

一般而言,对于可充电电池,尤其是含锂电池,充电不受用户(或开发人员)可以篡改的软件控制。这太危险了,因为锂电池过载会导致它们发生灾难性故障。也许你可以设法停止充电过程,但我对此表示怀疑。

Speaking generally about rechargeable batteries, especially Lithium containing ones, the charging is NOT controlled by software the user (or developer) can tamper with. This would be way too dangerous as overloading Lithium batteries will cause them to fail catastrophically. MAYBE you could manage to make the charging process stop, but I doubt that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文