This is likely an issue with me not properly understanding threading, however I often try and group code into a seperate class and become hindered by some it not being on the UI thread. I can't find anything that properly explains this however. As an example:
public class MyActivity extends Activity {
@Override
public void onCreate (Bundle bundle) {
HelperClass = new HelperClass(context);
}
}
public class HelperClass extends ContextWrapper {
someMethod () {
// Do stuff
}
}
When someMethod is called, if it's trying to do something thread dependant, I will get an error. I've had this with trying to keep some WebView logic in a seperate class as well as trying to access a realm database.
Using runnables seems very messy and I clearly don't understand exactly what's happening to beable to properly structure my code.
Can anyone explain why? and what the best soloution is?