-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2019-03-27:对于 Context,你了解多少? #14
Comments
了解不多 只知道 application service activity 都是具体的context |
以上两位层主推荐的文章都比较详细的说明了
篇幅原因,先不做详细讲解,后面会一一通过答题方式来探索。 |
1.Context是个抽象类 Activity跟Application跟Service都间接继承于他
|
|
1.Context本身是一个抽象类。 |
context是一个抽象类,Activity、Service、Application等都是该类的一个实现 |
@Moosphan 我整理了一下这个问题的回答,并翻译了一下推荐的英文博客,文章不错,看不下去英文的小伙伴可以看一下这篇译文。 |
Context 也叫上下文,是有关应用程序环境的全局信息的接口。这是一个抽象类, 它允许访问特定于应用程序的资源和类,以及对应用程序级操作的调用,比如启动活动,发送广播和接收意图等; Activity, Service, Application 都是 Context 的子类。 Context 的具体实现类是 ContextImpl, 还有一个包装类 ContextWrapper, ContextWrapper 的子类有 Service,Application,ContextThemeWrapper, Activity 又是 ContextThemeWrapper 的子类,ContextThemeWrapper 也可以叫 UI Context,跟UI 操作相关的最好使用此类 Context。 ContextWrapper 中有个 mBase,这个 mBase 其实是 ContextImpl,它是在Activity, Service, Application 创建时通过 attachBaseContext() 方法将各自对对应 ContextImpl 赋值的。对 context 的操作,最终实现都是在 ContextImpl。 对于 startActivity操作 getApplication()和getApplicationContext() 区别?
|
activity service application 都继承于context |
1 similar comment
activity service application 都继承于context |
了解它的拼写 |
No description provided.
The text was updated successfully, but these errors were encountered: