fix crash on API < 21
ScheduledLibraryUpdate extends JobService which requires API >= 21. This causes older versions to crash at startup as the whole ScheduledLibraryUpdate class does not 'exist' on older devices.
This commit is contained in:
parent
c0586a846f
commit
5006744dbc
@ -517,7 +517,9 @@ public final class PlaybackService extends Service
|
||||
mAccelLast = SensorManager.GRAVITY_EARTH;
|
||||
setupSensor();
|
||||
|
||||
ScheduledLibraryUpdate.scheduleUpdate(this);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
ScheduledLibraryUpdate.scheduleUpdate(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,7 +27,6 @@ import android.app.job.JobService;
|
||||
import android.content.Context;
|
||||
import android.content.ComponentName;
|
||||
import android.database.ContentObserver;
|
||||
import android.os.Build;
|
||||
|
||||
|
||||
@TargetApi(21)
|
||||
@ -50,9 +49,6 @@ public class ScheduledLibraryUpdate extends JobService {
|
||||
* @return true if job was scheduled, false otherwise
|
||||
*/
|
||||
public static boolean scheduleUpdate(Context context) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||
return false; // JobScheduler requires API 21
|
||||
|
||||
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
|
||||
|
||||
ComponentName componentName = new ComponentName(context, ScheduledLibraryUpdate.class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user