FeedUpdateReceiver was not registered in Manifest

fixes #566
This commit is contained in:
daniel oeh 2014-11-30 18:56:57 +01:00
parent d5181bf8f8
commit c49357c4d0
3 changed files with 31 additions and 31 deletions

View File

@ -19,10 +19,10 @@
<service
android:name=".service.playback.PlaybackService"
android:enabled="true"
android:exported="true"/>
android:exported="true" />
<service
android:name=".service.GpodnetSyncService"
android:enabled="true"/>
android:enabled="true" />
<receiver
android:name=".receiver.MediaButtonReceiver"
@ -47,6 +47,9 @@
</intent-filter>
</receiver>
<receiver android:name=".receiver.FeedUpdateReceiver">
</receiver>
</application>
</manifest>

View File

@ -20,6 +20,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import de.danoeh.antennapod.core.ApplicationCallbacks;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.R;
@ -582,8 +583,7 @@ public class UserPreferences implements
AlarmManager alarmManager = (AlarmManager) instance.context
.getSystemService(Context.ALARM_SERVICE);
PendingIntent updateIntent = PendingIntent.getBroadcast(
instance.context, 0, new Intent(
FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0);
instance.context, 0, new Intent(ClientConfig.applicationCallbacks.getApplicationInstance(), FeedUpdateReceiver.class), 0);
alarmManager.cancel(updateIntent);
if (intervalMillis != 0) {
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtMillis, intervalMillis,

View File

@ -7,40 +7,37 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import org.apache.commons.lang3.StringUtils;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBTasks;
/** Refreshes all feeds when it receives an intent */
/**
* Refreshes all feeds when it receives an intent
*/
public class FeedUpdateReceiver extends BroadcastReceiver {
private static final String TAG = "FeedUpdateReceiver";
public static final String ACTION_REFRESH_FEEDS = "de.danoeh.antennapod.feedupdatereceiver.refreshFeeds";
private static final String TAG = "FeedUpdateReceiver";
@Override
public void onReceive(Context context, Intent intent) {
if (StringUtils.equals(intent.getAction(), ACTION_REFRESH_FEEDS)) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Received intent");
boolean mobileUpdate = UserPreferences.isAllowMobileUpdate();
if (mobileUpdate || connectedToWifi(context)) {
DBTasks.refreshExpiredFeeds(context);
} else {
if (BuildConfig.DEBUG)
Log.d(TAG,
"Blocking automatic update: no wifi available / no mobile updates allowed");
}
}
}
@Override
public void onReceive(Context context, Intent intent) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Received intent");
boolean mobileUpdate = UserPreferences.isAllowMobileUpdate();
if (mobileUpdate || connectedToWifi(context)) {
DBTasks.refreshExpiredFeeds(context);
} else {
if (BuildConfig.DEBUG)
Log.d(TAG,
"Blocking automatic update: no wifi available / no mobile updates allowed");
}
}
private boolean connectedToWifi(Context context) {
ConnectivityManager connManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
private boolean connectedToWifi(Context context) {
ConnectivityManager connManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return mWifi.isConnected();
}
return mWifi.isConnected();
}
}