Android獲取系統(tǒng)內(nèi)核版本的方法
超過10多年行業(yè)經(jīng)驗,技術(shù)領(lǐng)先,服務(wù)至上的經(jīng)營模式,全靠網(wǎng)絡(luò)和口碑獲得客戶,為自己降低成本,也就是為客戶降低成本。到目前業(yè)務(wù)范圍包括了:做網(wǎng)站、網(wǎng)站設(shè)計,成都網(wǎng)站推廣,成都網(wǎng)站優(yōu)化,整體網(wǎng)絡(luò)托管,小程序設(shè)計,微信開發(fā),重慶APP軟件開發(fā),同時也可以讓客戶的網(wǎng)站和網(wǎng)絡(luò)營銷和我們一樣獲得訂單和生意!這里主要實現(xiàn)獲取Android Linux 內(nèi)核的版本號,網(wǎng)上關(guān)于這類文章不是很多,這里記錄下,希望能幫助到大家,
實現(xiàn)代碼:
public static String getKernelVersion() { String kernelVersion = ""; InputStream inputStream = null; try { inputStream = new FileInputStream("/proc/version"); } catch (FileNotFoundException e) { e.printStackTrace(); return kernelVersion; } BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 8 * 1024); String info = ""; String line = ""; try { while ((line = bufferedReader.readLine()) != null) { info += line; } } catch (IOException e) { e.printStackTrace(); } finally { try { bufferedReader.close(); inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } try { if (info != "") { final String keyword = "version "; int index = info.indexOf(keyword); line = info.substring(index + keyword.length()); index = line.indexOf(" "); kernelVersion = line.substring(0, index); } } catch (IndexOutOfBoundsException e) { e.printStackTrace(); } return kernelVersion; }