forked from baiiu/AndroidModule
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyApplication.java
More file actions
40 lines (31 loc) · 979 Bytes
/
Copy pathMyApplication.java
File metadata and controls
40 lines (31 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.baiiu.dagger2learn;
import android.app.Application;
import android.content.Context;
import com.baiiu.dagger2learn.di.component.AppComponent;
import com.baiiu.dagger2learn.di.component.DaggerAppComponent;
import com.baiiu.dagger2learn.di.module.ApplicationModule;
import com.baiiu.dagger2learn.util.LogUtil;
import javax.inject.Inject;
/**
* author: baiiu
* date: on 16/6/12 16:35
* description:
*/
public class MyApplication extends Application {
/*
需要是静态吗?
*/
private static AppComponent mAppComponent;
@Inject Context sContext;
@Override public void onCreate() {
super.onCreate();
mAppComponent = DaggerAppComponent.builder()
.applicationModule(new ApplicationModule(this))
.build();
mAppComponent.inject(this);
LogUtil.d(sContext.toString());
}
public static AppComponent getApplicationComponent() {
return mAppComponent;
}
}