You can link to my working sample code. Hope this helps!
public class MainActivity extends AppCompatActivity { private TextView mTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextView = (TextView) findViewById(R.id.textView); String url = "https://192.168.1.100/testvolley"; HurlStack hurlStack = new HurlStack() { @Override protected HttpURLConnection createConnection(URL url) throws IOException { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) super.createConnection(url); try { httpsURLConnection.setSSLSocketFactory(getSSLSocketFactory()); httpsURLConnection.setHostnameVerifier(getHostnameVerifier()); } catch (Exception e) { e.printStackTrace(); } return httpsURLConnection; } }; final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { mTextView.setText(response.toString(5)); } catch (JSONException e) { mTextView.setText(e.toString()); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { mTextView.setText(error.toString()); } }); final RequestQueue requestQueue = Volley.newRequestQueue(this, hurlStack); requestQueue.add(jsonObjectRequest); }
IMO, you should also read further Google Documentation - Security with HTTPS and SSL
BNK Sep 20 '15 at 0:08 2015-09-20 00:08
source share