I want to do some long operation (like copying/loading file) when the application is created. I created a thread to do so, that thread DOES NOT update UI. I got an error saying cannot create handler in a thread without calling Looper.prepare(). What's wrong with my code?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
threadFileManager = new Thread (
new Runnable() {
public void run() {
FileManager fM = new FileManager();
fM.copyFileFromAssetToStorage();
}
});
threadFileManager.start();
}
Edit:The error lied in my FileManager class, when it was a subclass of Activity. Changing to Service worked.