注入活动上下文匕首2.11错误

时间:2017-10-03 09:41:27

标签: android

我正在尝试在ImageUtls类中注入活动上下文:

.slick-slide img
display: block;
height: 500px;
width: 100%;

的AppModule:

public class ImageUtls {

private Context mContext;

   @Inject
   public ImageUtls(@ActivityContext Context context) {
       this.mContext = context;
   }
}

ActivityBuilder:

@Module
public class AppModule {

   @Provides
   @ActivityContext
   Context provideActivityContext(Activity activity) {
      return activity;
   }

   @Provides
   @ApplicationContext
   Context provideContext(Application application) {
      return application;
   }
}

OwnerActivityModule:

@Module
public abstract class ActivityBuilder {

  @ContributesAndroidInjector(modules = {OwnerActivityModule.class})
  abstract OwnerActivity bindOwnerActivity();

}

OwnerActivity注入:

@Module
public abstract class OwnerActivityModule {

  @Provides
  abstract Activity bindActivity(OwnerActivity activity);

}

AppComponent:

public class OwnerActivity extends BaseActivity {
    @Inject
    ImageUtls imageUtls;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
       AndroidInjection.inject(this);
       super.onCreate(savedInstanceState);

}

我没有收到有关出错的相关错误。任何人都可以解决这个问题吗?

0 个答案:

没有答案