Android Http请求失败解决方法

1、MainActivity.java 文件中的onCreate方法改成如下:

@SuppressLint("NewApi")

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads().detectDiskWrites().detectNetwork()
.penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()

.detectLeakedSqlLiteObjects().penaltyLog().penaltyDeath()

}


2、AndroidManifest.xml 里面的manifest加入配置


 
 

你可能感兴趣的:(Android)