I get a error of NetworkOnMainThreadException in the line of AVObject brandObj = query.getFirst();
After did some searches about the error, I think I should use something like Asynctask. But couldn't figure out how to do it.
AVObject
is same as ParseObject
public class Product {
Product(AVObject object) {
try {
AVObject brandObj = query.getFirst(); // this one is making network request
} catch (AVException e) {
e.printStackTrace();
}
}
}
Should I extends AsyncTask<AVObject, Void, AVObject>
Then
@Override
protected AVObject doInBackground(AVObject... objects) {
return null;
}
But not sure what should I write in doInBackground
Any suggestions?