I have a method that creates and calls a method from a library project. The library method loads data from a resource. I do this on a worker thread and NEVER touch the UI whilst doing so. The method making the call (on a worker thread) is:
private void testGetXData(){
try {
Data data = new Data();
String xsd = data.getXSD();
importedData = xsd;
} catch (Exception e) {
System.out.println(e.getMessage(););
}
}
and the exception happens on the line:
Data data = new Data();
Data
is a class in my library project. and importedData
is a module level String.
Edit
I am not using a handler directly. All I do to call the method is:
new Thread(new Runnable() {
public void run() {
testGetXData();
}
}).start();
I do it this way so as not to block the UI thread and get the dreaded ANR message. For completeness, I moved the resource to the library for sharing with a service. This worked fine when the resource was in the application project. It only now throws this exception since I moved it to the library project.
Furthermore
If I comment out the use of a worker thread and perform the call on the main thread, it works! I however want to do this on a background thread, which still throws the exception.