I want to perform network operation in other class. I have created a Runnable
in MainActivity
but I am having the exception NetworkOnMainThreadException
My question is do Runnable is not creating another thread from UI thread? I am new to Android development.
MainActivity.java
//Inside MainActivity Class
//.....
Runnable initStack = new Runnable(){
@Override
public void run(){
otherClassObject.itsMethod();
handler.post(new Runnable(){
//back to UI thread....
});
}
}