title: how to use HttpsUrlConnection instead of DefaultHttpClient
body: <p>DefaultHttpClient, ThreadSafeClientConnManager, HttpParams,HttpProtocolParams, SchemeRegistry, SSLSocketFactory, NameValuePair, HttpResponse are deprecated.</p>
  
  <p>I tried to use HttpsUrlConnection but i confused about them.</p>
  
  <pre><code>protected Gson gson;
  private ThreadSafeClientConnManager threadSafeClientConnManager;
  private DefaultHttpClient client;
  
  AbstractServiceApi() {
  
      // sets up parameters
      HttpParams params = new BasicHttpParams();
      HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
      HttpProtocolParams.setContentCharset(params, ENCODING);
      HttpConnectionParams.setConnectionTimeout(params, 95 * 1000);
      HttpConnectionParams.setSoTimeout(params, 95 * 1000);
      HttpConnectionParams.setStaleCheckingEnabled(params, false);
      params.setBooleanParameter("http.protocol.expect-continue", false);
  
      // registers schemes for both http and https
      SchemeRegistry registry = new SchemeRegistry();
      registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
      SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
      sslSocketFactory.setHostnameVerifier(SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
      registry.register(new Scheme("https", sslSocketFactory, 443));
  
      threadSafeClientConnManager = new ThreadSafeClientConnManager(params, registry);
      client = new DefaultHttpClient(threadSafeClientConnManager, params);
      gson = new Gson();
  }
  </code></pre>
  
  <p>I don't have an keystore. <a href="https://developer.android.com/reference/javax/net/ssl/HttpsURLConnection.html" rel="noreferrer">https://developer.android.com/reference/javax/net/ssl/HttpsURLConnection.html</a></p>
  
  <pre><code>   KeyStore keyStore = ...;
     String algorithm = TrustManagerFactory.getDefaultAlgorithm();
     TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm);
     tmf.init(keyStore);
  
     SSLContext context = SSLContext.getInstance("TLS");
     context.init(null, tmf.getTrustManagers(), null);
  
     URL url = new URL("https://www.example.com/");
     HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
     urlConnection.setSSLSocketFactory(context.getSocketFactory());
     InputStream in = urlConnection.getInputStream();
  </code></pre>
  
  <p>could anyone help me?</p>