Application
类是在 BroadcastReceiver
被调用时实例化的吗?我在自定义 Application 类中有一些逻辑,在运行 BroadcastReceiver
的 onReceive
中的逻辑之前需要这些逻辑。 The documentation onReceive
方法中的 Context
参数是接收器运行的 Context
。我不确定它是否是定义接收器的应用程序(静态地在 list 中)。
最佳答案
是的。 Application.onCreate 注释的文档:
Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created. If onCreate is called before your receiver is, it is by default instantiated first.
[1] http://developer.android.com/reference/android/app/Application.html#onCreate()
关于Android - 调用 BroadcastReceiver 时是否实例化了应用程序类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10799539/