zoukankan      html  css  js  c++  java
  • Android开发ABC之:Context

    SDK Doc中对Context的定义如下:

    Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc

    看代码,可以知道Context是一个抽象类,Android系统提供的实现是ContextImpl,它提供了对应用所执行的环境操作的功能,Context提供的功能包括:

    • Start/Stop Service
    • bind/unbind Service
    • register/unregister Receiver
    • start intentsender
    • start instrumentation
    • start Activity
    • Open/Create database
    • open file
    • . . . . .

    ContextHierarchy

    从这个类图关系,我们可以看出,没创建一个Activity、Service或者Application都会创建一个ContextImpl对象,但是多个ContextImpl中大部分操作都是由一个PackageInfo对象完成,也就是说不论创建多少Context,最后执行操作的都是一个PackageInfo对象。

  • 相关阅读:
    Angel investor
    [HNOI 2003]消防局的设立
    [USACO 08JAN]Telephone Lines
    [Luogu 2265]路边的水沟
    [NOI 2010]航空管制
    [HNOI 2004]敲砖块
    [Luogu 1730]最小密度路径
    [USACO 13NOV]No Change
    [POJ 1006]生理周期
    [AHOI 2012]树屋阶梯
  • 原文地址:https://www.cnblogs.com/whyandinside/p/2905028.html
Copyright © 2011-2022 走看看