Skip to content

Commit

Permalink
Add PackageInfo binding
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanenicolas committed Apr 17, 2016
1 parent 29c6ba4 commit 3df667b
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -9,6 +9,8 @@
import android.app.NotificationManager;
import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.hardware.SensorManager;
Expand Down Expand Up @@ -57,6 +59,17 @@ public ApplicationModule(Application application) {
bind(Resources.class).toProvider(ResourcesProvider.class);
bind(SharedPreferences.class).toProvider(SharedPreferencesProvider.class);
bindSystemServices(application);
bindPackageInfo(application);
}

private void bindPackageInfo(Application application) {
final PackageInfo packageInfo;
try {
packageInfo = application.getPackageManager().getPackageInfo(application.getPackageName(), 0);
bind(PackageInfo.class).to(packageInfo);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
}

// TODO check min sdk and refactor
Expand Down

0 comments on commit 3df667b

Please sign in to comment.