「Android誌」為程式碼自動上色 取得連結 Facebook X Pinterest 以電子郵件傳送 其他應用程式 12月 27, 2016 <pre class="codeblock prettyprint linenums:1"> 中間可以插入你想放入的程式碼 </pre> 取得連結 Facebook X Pinterest 以電子郵件傳送 其他應用程式 留言
「Android誌」Android處理SSL驗證 11月 27, 2016 錯誤代碼 javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. ---------------------------------------------------------------------------------------------------------------------- 解決方式 在製做電子發票驗證時、由於遇到網站憑證的問題、處理方式為避開SSL驗證 使用時先調用 requestWithoutCA 、再使用httpsurlconnection。 public void requestWithoutCA() { try { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, new TrustManager[] { new MyTrustManager() }, new SecureRandom()); HttpsURLConnection .setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection .setDefaultHostnameVerifier(new MyHostnameVerifier()); URL url = new URL("https://certs.cac.washington.edu/CAtest/"); HttpURLConnection urlConnection = (HttpURLConnection) url .openConnection(); InputStream in = urlConnection.getInputStream(); // 取得输入流,并使用Reader读取 BufferedReader reader = new BufferedReader( new InputStreamR... 閱讀完整內容
「Android誌」Android int to string, string to int, 整數轉字串、字串轉整數 12月 27, 2016 整數轉字串 String stringValue = Integer.toString(12345); String stringValue = String.valueOf(12345); 字串轉整數 int intValue = Integer.valueOf("12345"); int intValue = Integer.parseInt("12345"); 閱讀完整內容
留言
張貼留言