Skip to content

Commit

Permalink
target api proper handling in application module
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanenicolas committed Apr 17, 2016
1 parent 3df667b commit bcb6c95
Showing 1 changed file with 7 additions and 2 deletions.
@@ -1,6 +1,7 @@
package toothpick.smoothie.module;

import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.Application;
Expand Down Expand Up @@ -89,9 +90,13 @@ private void bindSystemServices(Application application) {
bindSystemService(application, TelephonyManager.class, TELEPHONY_SERVICE);
bindSystemService(application, AudioManager.class, AUDIO_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
bindSystemService(application, DownloadManager.class, DOWNLOAD_SERVICE);
bindForGingerBreadAndAbove(application);
}
bind(Application.class).to(application);
}

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void bindForGingerBreadAndAbove(Application application) {
bindSystemService(application, DownloadManager.class, DOWNLOAD_SERVICE);
}

private <T> void bindSystemService(Application application, Class<T> serviceClass, String serviceName) {
Expand Down

0 comments on commit bcb6c95

Please sign in to comment.