[android-developers] Re: getApplicationContext returns null in test case (unless you sleep first)

2009-03-04 Thread Dianne Hackborn
You are calling this while the app is running, and it hasn't finished initializing. Generally you should be very careful about directly touching app objects like this from tests, since the test is running in a separate thread. There are APIs to allow you to run code on the main thread to access i

[android-developers] Re: getApplicationContext returns null in test case (unless you sleep first)

2009-03-05 Thread AndyM
"There are APIs to allow you to run code on the main thread to access its objects." I'm a little confused about what APIs you are talking about and how they would help solve this problem. Could you clarify? To me it seems that the test runner should not be calling my tests if the Application is n

[android-developers] Re: getApplicationContext returns null in test case (unless you sleep first)

2009-03-05 Thread Dianne Hackborn
The framework runs the instrumentation independently of the app, so it can do what it wants when it wants. And an activity is not "the app". Activities are created all the time, you can't wait for whatever one to be created before running the instrumentation. http://developer.android.com/referenc