import java.net.HttpURLConnection; 
/* 检查网络连接是否正常 */   public boolean checkInternetConnection   (String strURL, String strEncoding)   {     /* 最多延时n秒若无应答则表示无法连接 */     int intTimeout = 5;     try     {       HttpURLConnection urlConnection= null;       URL url = new URL(strURL);       urlConnection=(HttpURLConnection)url.openConnection();       urlConnection.setRequestMethod("GET");       urlConnection.setDoOutput(true);       urlConnection.setDoInput(true);       urlConnection.setRequestProperty       (         "User-Agent","Mozilla/4.0"+         " (compatible; MSIE 6.0; Windows 2000)"       );              urlConnection.setRequestProperty       ("Content-type","text/html; charset="+strEncoding);            urlConnection.setConnectTimeout(1000*intTimeout);       urlConnection.connect();       if (urlConnection.getResponseCode() == 200)       {         return true;       }       else       {         return false;       }     }     catch (Exception e)     {       e.printStackTrace();       return false;     }   }


有时候google二维码api http://chart.apis.google.com/chart?chs="+
strWidth+"x"+strWidth+"&chl 不好用,可能是被墙了。可以用这个代替 http://qrcode.kaywa.com/img.php?s=5&d= (参数d和google里的chs一样)

// 判断是否为横屏if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {}// 判断是否为竖屏else if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {}


更多相关文章

  1. Android(安卓)AbsListView
  2. Android视频方向为什么出现问题以及Android视频应用开发中的处理
  3. 进程(一) 1.1 Android中异步处理大杀器——AsyncTask
  4. Cocos2d-x Lua实现从Android回调到Lua的方法
  5. Android使用WCF的服务程序之入门
  6. android二维码入库软件
  7. android中基于网络和GPS的不同精度定位
  8. Android指纹解锁,更好的接入到应用中
  9. android 支付宝SDK集成

随机推荐

  1. Android:在子线程中更新UI,解析异步消息
  2. 自定义View之继承View(圆形进度图,播放器条
  3. android 绘图 反锯齿办法
  4. android 自定义视图控件开发
  5. android客户端—AsyncTask的使用
  6. 极光推送的 4 种消息形式
  7. Android培训班(全世界最便宜,还送6410开发
  8. Android实践--apk反编译
  9. Android开发之--上传图片到七牛云存储
  10. Android人脸检测类FaceDetector