I am trying to wait for a background process to finish and then do some stuff accordingly after it finishes.
Basically I have a class TwitterActivity and an inner class CheckInternetConnection which extends AsyncTask. I have also a button mSignin and I set the event handling for it. In addition I have also a boolean hasInternet.
My aim is when the mSignin button will be pressed I will call CheckInternetConnection. This is supposed to update my boolean value hasInternet. Then accordingly I expect to do some stuffs. 
But I want exactly to do inside onClick() method.
Is there any way how to achieve it? Thanks.
public class TwitterActivity extends Activity 
{
    private boolean hasInternet = false;
    private Button mSignin;
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_twitter);
        mSignin = (Button)findViewById(R.id.login_id);
        mSignin.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                new CheckInternetConnection().execute();
                if(hasInternet)
                    //do some stuff
                else
                    //do some other stuff
            }
        });
    } 
    class CheckInternetConnection extends AsyncTask<Void, Void, Boolean>{
        @Override
        protected void onPostExecute(Boolean result){
            if(result)
                hasInternet = true;
            else
                hasInternet = false;
        }
        @Override
        protected Boolean doInBackground(Void... params) {
            return true;
        }
    }
}
 
     
     
    