首页 > 解决方案 > 无法解析主机名意味着如何在 android studio 的异步任务中解析它

问题描述

无法解析主机名以下代码段:

public class Main2Activity extends Activity {

// button to show progress dialog
Button btnShowProgress;

// Progress Dialog
private ProgressDialog pDialog;
ImageView my_image;
// Progress dialog type (0 - for Horizontal progress bar)
public static final int progress_bar_type = 0;

// File url to download
private static String file_url = "https://www.tutorialspoint.com/images/tp-logo-diamond.png";
}                                                                          

标签: javaandroid

解决方案


检查您是否没有在 AndroidMenifext.xml 中使用互联网权限

<uses-permission android:name="android.permission.INTERNET" />

还要在运行时请求相同的权限。


推荐阅读