Merge pull request #696 from TomHennen/autodownload_bug
for some reason the intent doesn't have EXTRA_STATUS anymore. We'll just...
This commit is contained in:
commit
a021c455ac
|
@ -13,16 +13,19 @@ import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||||
|
|
||||||
// modified from http://developer.android.com/training/monitoring-device-state/battery-monitoring.html
|
// modified from http://developer.android.com/training/monitoring-device-state/battery-monitoring.html
|
||||||
// and ConnectivityActionReceiver.java
|
// 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 {
|
public class PowerConnectionReceiver extends BroadcastReceiver {
|
||||||
private static final String TAG = "PowerConnectionReceiver";
|
private static final String TAG = "PowerConnectionReceiver";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
final String action = intent.getAction();
|
||||||
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
|
||||||
status == BatteryManager.BATTERY_STATUS_FULL;
|
|
||||||
|
|
||||||
if (isCharging) {
|
Log.d(TAG, "charging intent: " + action);
|
||||||
|
|
||||||
|
if (Intent.ACTION_POWER_CONNECTED.equals(action)) {
|
||||||
Log.d(TAG, "charging, starting auto-download");
|
Log.d(TAG, "charging, starting auto-download");
|
||||||
// we're plugged in, this is a great time to auto-download if everything else is
|
// 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
|
// right. So, even if the user allows auto-dl on battery, let's still start
|
||||||
|
|
Loading…
Reference in New Issue