Code example for Activity

Methods: getApplication, getClass, setTheme

0
  public void setApplication(Application application) {
    field("mApplication").ofType(Application.class).in(realActivity).set(application);
  } 
 
  public boolean setThemeFromManifest() { 
    ShadowApplication shadowApplication = shadowOf(realActivity.getApplication());
    AndroidManifest appManifest = shadowApplication.getAppManifest();
    if (appManifest == null) return false;
 
    String themeRef = appManifest.getThemeRef(realActivity.getClass());
 
    if (themeRef != null) {
      ResName style = ResName.qualifyResName(themeRef.replace("@", ""), appManifest.getPackageName(), "style");
      Integer themeRes = shadowApplication.getResourceLoader().getResourceIndex().getResourceId(style);
      if (themeRes == null)
        throw new Resources.NotFoundException("no such theme " + style.getFullyQualifiedName());
      realActivity.setTheme(themeRes);
      return true; 
    } 
    return false; 
  }