getApplicationContext returns null in test case (unless you sleep first)

by Dianne Hackborn » Thu, 05 Mar 2009 03:58:08 GMT

Sponsored Links
 You are calling this while the app is running, and it hasn't finished

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 its objects.

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.


Other Threads

1. Using Picture recording creates bad memory allocation

I use this approach for my main game loop because surface view is
jerky and drawing direct to image misses the double buffer effects, so
different parts of my image update at different times.

Picture.beginRecording works very smoothly, but DDMS indicates bad
memory allocation from the beginRecording method.

Canvas canvas = picture.beginRecording(320, 480);

I tracked the issue down to this line in the Picture.beginRecording
method :
 59         mRecordingCanvas = new RecordingCanvas(this, ni);

Hence no surprise about the allocation. But does this mean that there
is no way to use the Picture object in a game loop without causing
memory leaks / slowdown?

Kind of makes the whole Picture class redundant if there's no way
around this ...;a=blob;f=graphics/java/android/graphics/;h=bbb2dbfa6abdf48b63ddfacc07fa2a7914a06e83;hb=cupcake


2. Inserting Data into a Cursor?

Hello, I'm looking for a way to insert data into a cursor that is
separate from the SQL database it retrieves the rest of the
information from.
Is there any way to to this, or is there a different way to add more
information to a list view item?

What I'm trying to do is to use a date column for each entry in the
list to calculate the number of days until that date (and then put
that number in the list item).
I know how to get the value, but I just cant find a way to put it into
the list without it being in the cursor.


3. Mouse Events in Browser

4. browser plugin development?

5. Dueling Activities Over the Intent's Hand in Marriage

6. Problem with a AndroidManifest.xml for a service

7. Out of memory exceptions and difference between emulator and hardware (dev phone)