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. Setting (virtual interface / sub-interface / IP aliasing) with SDK (or NDK)

I need to configure two different IPs for the same network interface
in Android (mostly WiFi, but also ethernet when available). I need to
set a IP for being able to receive multimedia
streams from my provider and then I need to export them to the private
network (DHCP managed).

I have been searching through the APIs and I have only found
references to sub-interfaces and virtual interfaces: there's no
function for setting them. Is it possible to set a secondary aliased
IP using the SDK or even the NDK for a regular Android app? How?

Thanks in advance


2. exception while accessing MS SQL 2005 express using JDBC

I downloaded JDBC driver from
(sqljdbc_3.0.1301.101_enu.exe), and use sqljdbc4.jar file in my code,
to connect with MS SQL 2005 Express.

I wrote very simple code. It provides exception while doing
String driver= ""; //
Start JDBC
String dbURL = "jdbc:sqlserver://\
String user="sa",pass="abc@123";
java.sql.Connection dbConn = null;
        dbConn = DriverManager.getConnection(dbURL,user,pass);
catch (Exception e)
code is working properly when it is run from windows system.
On android system,
"class.forname(driver);" is working properly.
"getconnection()" function fails; it throws exception that
" The driver could not
establish a secure connection to SQL Server by using Secure Sockets
Layer (SSL) encryption. Error: "Unable to make socket non blocking"."

Can you please help into this?



3. Why does Ginger's NetworkLocation.apk use "" instead of "andorid.ui.system" ?

4. Graphics shape intersected by rectangle. Is there an easy way to do it in android?

5. Reflection And Library Diferrent Classes Definition

6. other possible error cause

7. To many Images in Horizontalscrollview?