I have a method called hostPhoto(); it basically uploads an image to a site and retrieves a link.
I then have an other method to post the link to a website.
You can use AsyncTask here,
AsyncTask
By Using that you can execute the code of
hostPhoto()
in doInBackground() and then execute the code of
post(text+" "+link);
in the onPostExecute() Method, that will the best solution for you.
You can write the code in this pattern
private class MyAsyncTask extends AsyncTask
{
@Override
protected Void doInBackground(Void... params) {
hostPhoto();
return null;
}
@Override
protected void onPostExecute(Void result) {
post(text+" "+link);
}
}
and the can execute it using
new MyAsyncTask().execute();