I can do it in java with this code:
String url = "http://t.co/i5dE1K4vSs";
URLConnection conn = new URL( url ).openConnection();
System.out.println( "orignal url: " + conn.getURL() );
conn.connect();
System.out.println( "connected url: " + conn.getURL() );
InputStream inputS = conn.getInputStream();
System.out.println( "redirected url: " + conn.getURL() );
inputS.close();
Now in android when a button is clicked it calls :
public void followRedirects(View v) throws ClientProtocolException, IOException, URISyntaxException
{
String url = "http://t.co/i5dE1K4vSs";
URLConnection conn = new URL( url ).openConnection();
System.out.println( "orignal url: " + conn.getURL() );
conn.connect();
System.out.println( "connected url: " + conn.getURL() );
InputStream inputS = conn.getInputStream();
System.out.println( "redirected url: " + conn.getURL() );
inputS.close();
}
This is my error log in android