To get the property set by 'setprop', there are two options:
One. use android.os.SystemProperties, this is a hide API. use it like this:
Class clazz = null;
clazz = Class.forName("android.os.SystemProperties");
Method method = clazz.getDeclaredMethod("get", String.class);
String prop = (String)method.invoke(null, "AP");
Log.e("so_test", "my prop is: <" + prop + ">");
Two. use 'getprop' utility:
Process proc = Runtime.getRuntime().exec(new String[]{"/system/bin/getprop", "AP"});
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
Log.e("so_test", "my prop is: " + reader.readLine());
Maybe using functions availble in NDK is an option too, but why bother?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…