java - 无法解析主机名意味着如何在 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";
}
解决方案
检查您是否没有在 AndroidMenifext.xml 中使用互联网权限
<uses-permission android:name="android.permission.INTERNET" />
还要在运行时请求相同的权限。
推荐阅读
- c++ - Why does the local variable in my thread function get interrupted by other threads?
- node.js - 从 cloudstar 生成的应用程序在 AWS cloud9 中快速运行 express 应用程序?
- c++ - C ++不合格名称查找:不同cpp中的不同结构大小导致运算符new分配的内存少于构造函数进程?
- java - 如何以编程方式获取所有相邻小区信息?
- android - SSL证书问题:Android Studio证书链中的自签名证书
- python - 如何创建 CSV 文件的标题?
- css - Wordpress 没有在移动设备上显示部分 CSS
- c - 将操作应用于 C 中的整个内存块
- python - 在 PyCharm 的远程解释器上运行远程脚本
- tensorflow - Keras中层之间的身份连接应该怎么做?