I have a function, AppHelper.isOnline(Context context), I call in various parts of my application to check that a session didn\'t timeout before making an HTTP
AppHelper.isOnline(Context context)
intent = new Intent(this, OrdineCreaActivity.class); context.startActivityForResult(intent, R.id.buttonPagamenti);
Write the above lines in onPostExecute() of you AysncTask. Because if we are using AsyncTask it wont wait there until the task complete.