简体   繁体   English

如何发送 android 系统意图?

[英]How to send an android system intent?

Because of the bug described here i want to write a little android app to fix the problem in an indirect approach.由于此处描述的错误,我想编写一个小 android 应用程序以间接方法解决问题。

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#).我是 java 和 android 应用程序的新手(尽管我非常了解 c,Z6CE809#4BD900BA12EZ03)

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 .我想出的是发送一个名为 BATTERY_CHANGED 的意图,如此所述。

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

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.也许您可以设法停止充电过程,但我对此表示怀疑。

Sending ACTION_BATTERY_CHANGED will not affect the charging, even if you could broadcast it yourself, which only the firmware can do.发送ACTION_BATTERY_CHANGED不会影响充电,即使你可以自己广播它,只有固件可以做到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM