2

aが呼び出されたときにApplicationクラスがインスタンス化されますか?aBroadcastReceiverのロジックを実行する前に必要なカスタムApplicationクラスにいくつかのロジックがあります。ドキュメントには、メソッドの引数はレシーバーが実行されている場所であると記載されています。受信者が(マニフェストで静的に)定義されているアプリケーションであるかどうかはわかりませんでした。onReceiveBroadcastReceiverContextonReceiveContext

4

2 に答える 2

2

Yes. The documentation for Application.onCreate notes:

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()

于 2015-01-17T01:24:18.940 に答える
-1

To answer this question you can try an expriment. Just extends the Application and log it's class in onReceive() :

Log.d(TAG, "Context is " + context.getClass().getName());
于 2012-05-29T12:53:50.340 に答える