I'm a noob with Android development, so bear with me. I'm trying to figure out how to make a secure HTTPS POST in Android for a REST API call, and I tried the following method (provided at Secure HTTP Post in Android)
private HttpClient createHttpClient()
{
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
HttpProtocolParams.setUseExpectContinue(params, true);
SchemeRegistry schReg = new SchemeRegistry();
schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schReg);
return new DefaultHttpClient(conMgr, params);
}
However, I pasted this into my code, and I think I imported everything that's necessary, but Eclipse is complaining about this line:
schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
It says "The method getSocketFactory() is undefined for the type SSLSocketFactory". Has this been deprecated, and is there a newer way to do this?
Any help would be much appreciated. Thanks.