android - Get wireless charging info -
i write app logging battery status, there problem batterymanager.battery_plugged_wireless. if load galaxy s3 android 4.0.4 or s4 4.2.2 on wireless charging station, app display 1 (battery_plugged_ac) instead of 4 (battery_plugged_wireless). phone display popup, notice wireless charging. api bug?
can confirm this? there other workaround charging mode?
public class batteryreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { int plugged = intent.getintextra(batterymanager.extra_plugged, 0); toast.maketext(context, errormsg, toast.length_short).show(); } }
if right want know if device charging or not. think problem solution should written this:
public class datareceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { if(intent.getaction().equalsignorecase(intent.action_power_connected)) { //do when device charging } else if(intent.getaction().equalsignorecase(intent.action_power_disconnected)) { //do when device not charging } } } in xml receiver this.
<receiver android:name=".datareceiver" android:enabled="true"> <intent-filter> <action android:name="android.intent.action.action_power_connected"/> <action android:name="android.intent.action.action_power_disconnected"/> </intent-filter> </receiver> hope helped you. :-)
Comments
Post a Comment