答案 0 :(得分:1)
你可以尝试这个
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Thread(new Runnable() {
@Override
public void run() {
String expandedURL1=expand("YOUR SHORT URL");
Log.d("Expanded", "run: "+expandedURL1);
}
}).start();
}
public static String expand(String url) {
String s3 = "";
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
int s = connection.getInputStream().read();
URL s2 = connection.getURL();
s3 = String.valueOf(s2);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return s3;
}
}
您将在logcat中获得扩展的URL D /扩展:运行:“扩展的URL”