title: Null pointer exception of Dagger-2 (android)
body: <h2>Details</h2>
  
  <p>Null pointer Exception on UseContex class while using 'printToast()' method of UseContex class.UseContex class extends the mainActivity.If i print toast in MainActivity than it doe's not contain null pointer on context object but same thing don in UseContex than it show null pointer exception.</p>
  
  <h2>AppComponent</h2>
  
  <pre><code>@Singleton @Component(modules = {AppModule.class})
  public interface AppComponent {
  void inject(DaggerApplication daggerApplication);
  void inject(MainActivity mainActivity);
  </code></pre>
  
  <p>}</p>
  
  <h2>AppModule</h2>
  
  <pre><code>@Module
  public class AppModule {
  private final DaggerApplication application;
  public AppModule(DaggerApplication application) {
      this.application = application;
  }
  @Singleton
  @Provides
  Context providesApplicationContext(){
      return  application;
  }
  @Singleton
  @Provides
  UseContex provideUsecontex(){
    return new UseContex();
  }
  }
  </code></pre>
  
  <h2>UseContex</h2>
  
  <pre><code>public class UseContex extends MainActivity{
  public  void printToast(){
  Log.e("User dao impl","Hello user dao");
  Toast.makeText(context, "helo", Toast.LENGTH_SHORT).show();
  }
  }
  </code></pre>
  
  <h2>MainActivity</h2>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  @Inject
  UseContex useContex;
  @Inject
  public Context context;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);    
  ((DaggerApplication)getApplication()).getAppComponent().inject(this);
       useContex.printToast();
  }
  }
  </code></pre>
  
  <h1>DaggerApplication</h1>
  
  <pre><code>public class DaggerApplication extends Application {
  AppComponent appComponent;
  @Override
  public void onCreate() {
      super.onCreate();
      appComponent = DaggerAppComponent.builder().appModule(new 
  AppModule(this)).build();
      appComponent.inject(this);
  
  }
  public AppComponent getAppComponent(){return  appComponent;}
  
  }
  </code></pre>