//判断网路
public static boolean InNetWork(Context context){
if (context!=null){
ConnectivityManager manager=(ConnectivityManager)context.getSystemService(context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
if (info!=null){
return info.isAvailable();
}
}
return false;
}
//请求数据
public static String httpGet(String strUrl){
//字符串转换为URL
try {
URL url=new URL(strUrl);
HttpURLConnection connection=(HttpURLConnection) url.openConnection();
//设置超时时间
connection.setConnectTimeout(5000);
//设置读取超时时间
connection.setReadTimeout(5000);
//设置请求方式
connection.setRequestMethod("GET");
//判断请求码
if (connection.getResponseCode()==200){
InputStream inputStream = connection.getInputStream();
InputStreamReader streamReader=new InputStreamReader(inputStream);
Buffered