4

In Axon ZTE device, when I run the reciver

private String isConnected(Context context) {
    String sRet = "";
    try {
        final Intent mIntent = context.getApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
        int plugged = mIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);

        if ((plugged == BatteryManager.BATTERY_PLUGGED_AC) && ac_connected == false) {
            ac_connected = true;
            sRet = "AC";
        } else if (plugged == BatteryManager.BATTERY_PLUGGED_USB) {
            ac_connected = true;
            sRet = "USB";
            //Toast.makeText(ctx, "connected to usb ", Toast.LENGTH_LONG).show();

        } else {
            sRet = "NOT CHARGING";
        }
    } catch (Exception e) {
        sRet = "";
    }

    return sRet;

}

It always returns "AC" instead USB ,in other devices the reciver runs well. How could it happend?

Eli Elezra
  • 525
  • 2
  • 4
  • 18

1 Answers1

0

I'm seeing similar behavior. It might be that the device manufacturer / ROM isn't reporting correctly. nothing much to do unless you prefer digging into device logs you'll might be able to do some queries in the terminal.

Rock_Artist
  • 555
  • 8
  • 14