diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2015-03-26 21:17:41 -0400 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2015-03-26 21:17:41 -0400 |
commit | abdf9a3f2839fdde04a1c0096705897497b4bebe (patch) | |
tree | 31686387625d8ed310fdd3e1c67690e1aaba8880 /app/src/main/java/de/danoeh | |
parent | f5a824ce1b2dcdd5bb3e32e04fdfe84afdaacad6 (diff) | |
download | AntennaPod-abdf9a3f2839fdde04a1c0096705897497b4bebe.zip |
for some reason the intent doesn't have EXTRA_STATUS anymore. We'll just see what the action type is. closes #695
Diffstat (limited to 'app/src/main/java/de/danoeh')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java index 0e7784381..f050e031d 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java @@ -13,16 +13,19 @@ import de.danoeh.antennapod.core.storage.DownloadRequester; // modified from http://developer.android.com/training/monitoring-device-state/battery-monitoring.html // and ConnectivityActionReceiver.java +// Updated based on http://stackoverflow.com/questions/20833241/android-charge-intent-has-no-extra-data +// Since the intent doesn't have the EXTRA_STATUS like the android.com article says it does +// (though it used to) public class PowerConnectionReceiver extends BroadcastReceiver { private static final String TAG = "PowerConnectionReceiver"; @Override public void onReceive(Context context, Intent intent) { - int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1); - boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || - status == BatteryManager.BATTERY_STATUS_FULL; + final String action = intent.getAction(); - if (isCharging) { + Log.d(TAG, "charging intent: " + action); + + if (Intent.ACTION_POWER_CONNECTED.equals(action)) { Log.d(TAG, "charging, starting auto-download"); // we're plugged in, this is a great time to auto-download if everything else is // right. So, even if the user allows auto-dl on battery, let's still start |