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.

 http://developer.android.com/reference/android/app/Instrumentation.html 

 http://developer.android.com/reference/android/app/Instrumentation.html #onStart()

 http://developer.android.com/reference/android/app/Instrumentation.html #runOnMainSync(java.lang.Runnable)








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

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)

Hello,
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 10.151.190.121/29 IP for being able to receive multimedia
streams from my provider and then I need to export them to the private
network 192.168.1.1/24 (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

Hi,
I downloaded JDBC driver from microsoft.com
(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
getConnection().
************************
String driver= "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //
Start JDBC
String dbURL = "jdbc:sqlserver://192.168.1.2\
\sqlexpress;databaseName=dbname;encrypt=true;trustServerCertificate=false";
String user="sa",pass="abc@123";
java.sql.Connection dbConn = null;
try
{
    Class.forName(driver);
        dbConn = DriverManager.getConnection(dbURL,user,pass);
        dbConn.close();
}
catch (Exception e)
{
    e.printStackTrace();
}
**********************
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
"com.microsoft.sqlserver.jdbc.SQLServerException: 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?

Thanks
Niket

-- 

3. Why does Ginger's NetworkLocation.apk use "com.google.uid.shared" 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?