I use AsyncTask to connect an URLPath as below code.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Save the HttpURLConnection response by (HttpURLConnection)url.openConnection(); as a class member: HttpURLConnection mHttpURLConnection = (HttpURLConnection)url.openConnection();
after you call future.cancel(true); then call mHttpURLConnection.disconnect()
so the network request will end as fast as possible