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

by Dianne Hackborn » Fri, 06 Mar 2009 04:12:05 GMT

Sponsored Links
 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. #onStart() #runOnMainSync(java.lang.Runnable)

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. Offloading data from an android app

What is the recommended approach?
I am planning to create a file in the getExternalStorageDirectory()
and then move that file to something external

First I thought of emailing that file as an attachment. However I
cannot seem to locate an Intent that allows me to generate the email.
I suspect that one is not allowed to do that.

Next I thought of offloading via the USB port to a laptop/desktop.

Can anyone point me to examples of eitherf approach?

Thanks in Advance.


2. Help me out with my Listview custom row layout, I already tried many combinations

There are some errors I found. Have a look at this xml.

But without knowing what exactly you want, I can't really help you
with the layout. A screenshot will be helpful.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="
        <ImageView android:id="@+id/icon" android:layout_width="48dip"
                android:layout_height="48dip" android:src="@drawable/icon"
                android:layout_marginRight="4dip" />
        <ImageButton android:id="@+id/android_button"
                android:layout_width="48dip" android:layout_height="48dip"
                android:src="@drawable/icon" android:background="#00000000"
centerText" />
        <LinearLayout android:id="@+id/centertext"
                <TextView android:id="@+id/titletext" android:textSize="16sp"
                        android:textStyle="bold" android:text="Text One"
android:layout_height="wrap_content" />
                <TextView android:id="@+id/summarytext"
                        android:singleLine="false" android:text="Text Two" />

Thanks and Regards,
Kumar Bibek


3. /log/dev/radio, /log/dev/events

4. Setting background color on row layout prevents display of highlight on select

5. ListView with sections from a SINGLE Cursor

6. Correct way to set up buffer for glReadPixels?

7. ListView with sections from a SINGLE Cursor