Q:

How to check whether url scheme is Http or Https and create URLConnection depending on it

So basically right now my app is configured to use https because in the "release" it will use a self signed certificate and obviously also use Https. 
My current testsystem (few more features) doesn't use https but http instead.  I thought it would be kinda nice to have some type of method to check whether the given URL is Http or Https and depending on the result create the right URLConnection. 
My current problem is that I don't know what the method should exactly look like.  I thought about using if-statements in the methods which connect to my server but there might be a better solution. 
Help would be appreciated. 

A:

How about this:
URLUtil.isHttpUrl(String url)
URLUtil.isHttpsUrl(String url)

See also: http://developer.android.com/reference/android/webkit/URLUtil.html
If you don't want to do a manual check you can use a 3rd party library like this one: http://square.github.io/okhttp/ which allows you a simple:
Request request = new Request. Builder().url(url).build();
Response response = new OkHttpClient().newCall(request).execute();

