我目前有一个媒体播放器,正在尝试从我的源路径获取重定向地址。由于媒体播放器不支持重定向处理,我正在尝试通过创建HttpURLConnection等方式获取重定向的URL路径。但是,我不确定我是否做得对。任何帮助将不胜感激。谢谢。
代码:
代码:
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);