title: Android - obtain url redirect
body: <p>I currently have a mediaplayer and am trying to get the redirect address from my source path. Since the media player does not support redirect handling, I am trying to get the redirected url path by creating a httpurlconnection etc. However, I'm not sure if I am doing it right. Any help would be appreciated. Thanks.</p>
  
  <p>Code: </p>
  
  <pre><code>Log.d(TAG, "create url - test");
  URL testUrl = new URL(path);
  HttpURLConnection conn = (HttpURLConnection)testUrl.openConnection();
  
  String test = conn.getURL().toString();
  String test1 = conn.getHeaderField(2);
  String test2 = conn.toString();
  Log.d(TAG, "normal stuff test is: " + test);
  Log.d(TAG, "header field test is: " + test1);
  Log.d(TAG, "url to string is: " + test2);
  </code></pre>