編輯:關於Android編程
1 查看手機CPU信息
cmd——adb shell——cd /proc------cat cpuinfo
2 獲取cpu的是arm指令集,armv7指令集、還是neon指令集<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PC9wPgo8cHJlIGNsYXNzPQ=="brush:java;"> /**
*
* [獲取cpu類型和架構]
*
* @return
* 三個參數類型的數組,第一個參數標識是不是ARM架構,第二個參數標識是V6還是V7架構,第三個參數標識是不是neon指令集
*/
public static Object[] getCpuArchitecture() {
if ((Integer) mArmArchitecture[1] != -1) {
return mArmArchitecture;
}
try {
InputStream is = new FileInputStream("/proc/cpuinfo");
InputStreamReader ir = new InputStreamReader(is);
BufferedReader br = new BufferedReader(ir);
try {
String nameProcessor = "Processor";
String nameFeatures = "Features";
String nameModel = "model name";
String nameCpuFamily = "cpu family";
while (true) {
String line = br.readLine();
String[] pair = null;
if (line == null) {
break;
}
pair = line.split(":");
if (pair.length != 2)
continue;
String key = pair[0].trim();
String val = pair[1].trim();
if (key.compareTo(nameProcessor) == 0) {
String n = "";
for (int i = val.indexOf("ARMv") + 4; i < val.length(); i++) {
String temp = val.charAt(i) + "";
if (temp.matches("\\d")) {
n += temp;
} else {
break;
}
}
mArmArchitecture[0] = "ARM";
mArmArchitecture[1] = Integer.parseInt(n);
continue;
}
if (key.compareToIgnoreCase(nameFeatures) == 0) {
if (val.contains("neon")) {
mArmArchitecture[2] = "neon";
}
continue;
}
if (key.compareToIgnoreCase(nameModel) == 0) {
if (val.contains("Intel")) {
mArmArchitecture[0] = "INTEL";
mArmArchitecture[2] = "atom";
}
continue;
}
if (key.compareToIgnoreCase(nameCpuFamily) == 0) {
mArmArchitecture[1] = Integer.parseInt(val);
continue;
}
}
} finally {
br.close();
ir.close();
is.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return mArmArchitecture;
}
調用的該函數的示例方法
/* * 獲取FFpeg解碼庫的名稱(如果是插件,會涉及到一個向下兼容的問題,例如:如果當前cpu是V7neo,而又沒有neon的解碼庫,必須要做向下兼容出來 * ,如果有V7的庫就加載V7的庫,有V6的庫就加載V6的) */ public static String getFFmpegLibName(Context context) { if (LIB_FFMPEG_NAME != null) { return LIB_FFMPEG_NAME; } Object[] arch = getCpuArchitecture(); String libDir = getNativeLibraryDir(context); String libSysDir = "/system/lib"; if ("ARM".equals(arch[0])) { try { String ffmpeg = String.format("ffmpeg-%d%s", (Integer) arch[1], (String) arch[2]); if (isFileExist(libDir + "/lib" + ffmpeg + ".so") || isFileExist(libSysDir + "/lib" + ffmpeg + ".so")) { return ffmpeg; } else { boolean isV7NeonCpu = "neon".equals(arch[2]); boolean isV7 = ((Integer) arch[1]) == 7 && "".equals(arch[2]); boolean isV6 = ((Integer) arch[1]) == 6; if (isV7NeonCpu) { if (isFileExist(libDir + "/libffmpeg-7neon.so") || isFileExist(libSysDir + "/libffmpeg-7neon.so")) { LIB_FFMPEG_NAME = "ffmpeg-7neon"; return "ffmpeg-7neon"; } else if (isFileExist(libDir + "/libffmpeg-7.so") || isFileExist(libSysDir + "/libffmpeg-7.so")) { LIB_FFMPEG_NAME = "ffmpeg-7"; return "ffmpeg-7"; } else if (isFileExist(libDir + "/libffmpeg-6.so") || isFileExist(libSysDir + "/libffmpeg-6.so")) { LIB_FFMPEG_NAME = "ffmpeg-6"; return "ffmpeg-6"; } } else if (isV7) { if (isFileExist(libDir + "/libffmpeg-7.so") || isFileExist(libSysDir + "/libffmpeg-7.so")) { LIB_FFMPEG_NAME = "ffmpeg-7"; return "ffmpeg-7"; } else if (isFileExist(libDir + "/libffmpeg-6.so") || isFileExist(libSysDir + "/libffmpeg-6.so")) { LIB_FFMPEG_NAME = "ffmpeg-6"; return "ffmpeg-6"; } } else if (isV6) { if (isFileExist(libDir + "/libffmpeg-6.so") || isFileExist(libSysDir + "/libffmpeg-6.so")) { LIB_FFMPEG_NAME = "ffmpeg-6"; return "ffmpeg-6"; } } } } catch (Exception e) { e.printStackTrace(); } } else if ("INTEL".equals(arch[0])) { if (isFileExist(libDir + "/libffmpeg-x86atom.so") || isFileExist(libSysDir + "/libffmpeg-x86atom.so")) { LIB_FFMPEG_NAME = "ffmpeg-x86atom"; return "ffmpeg-x86atom"; } } LIB_FFMPEG_NAME = null; return null; }
一、廣播發送者&廣播接收者介紹1.廣播接收者廣播接收者簡單地說就是接收廣播意圖的Java類,此Java類繼承BroadcastReceiver類,重寫:public vo
這個動畫效果是把Activity當做一張紙,正反面都有內容,且當點擊正反面的任何一個翻轉按鈕,Activity都會以屏幕中心為翻轉中心點(Z軸的翻轉中心點可以自由設定),
在drawable文件夾中建立如下旋轉動畫文件 android:drawable=@drawable/loading1 android:p
Android網絡編程之獲取網絡上的XML 請尊重他人的勞動成果,轉載請注明出處:Android網絡編程之獲取網絡上的XML 為要獲取網絡上的XML所以需要