标签:android style class blog code java
Android命令行/c语言/java设置获取系统属性的方法SystemProperties.getInt("persist.sys.boot_music_control", 0) SystemProperties.set("persist.sys.boot_music_control", ""+value);
char boot_music_control[PROPERTY_VALUE_MAX]; if (property_get("persist.sys.boot_music_control", boot_music_control, 0) != 0) { mediastatus = mediaplayer->setDataSource(pBackupSoundFileName, NULL); }
system/core/libcutils/properties.c #define PROPERTY_KEY_MAX 32 #define PROPERTY_VALUE_MAX 92 int property_get(const char *key, char*value, const char *default_value); int property_set(const char *key, constchar *value); int property_list(void (*propfn)(const char *key, constchar *value, void*cookie), void *cookie);
#include "cutils/properties.h" char prop[PROPERTY_VALUE_MAX] = "000"; if(property_get("prop_name", prop, NULL) != 0) { ... }
<span style="font-size:14px;">public static final int PROP_NAME_MAX = 31; public static final int PROP_VALUE_MAX = 91; public static String get(String key) ; public static String get(String key, String def) ; public static int getInt(String key,int def) ; public static long getLong(String key,long def) ; public static boolean getBoolean(String key, boolean def) ; public static void set(String key, String val) ; public static void addChangeCallback(Runnable callback) ; </span>
遇到问题解决:
1.在Setting中添加开关使用getProperty()和setProperty()属性来进行属性的获取和设置,在命令行使用
adb shell getprop
来查看属性的值:
[persist.service.adb.enable]: [] [persist.sys.ams.recover]: [false] <span style="color:#FF0000;">[persist.sys.boot_music_control]: [1]</span> [persist.sys.bootpackage]: [1] [persist.sys.btn_auto_light]: [1]
<span style="color:#FF0000;">persist.sys.boot_music_control</span>
解决:
//Modfy by jjli,control the boot and shutdown music char boot_music_control[PROPERTY_VALUE_MAX]; property_get("persist.sys.boot_music_control", boot_music_control, 1); int boot_music_value = atoi(boot_music_control); if (boot_music_value == 1) { mediastatus = mediaplayer->setDataSource(pBackupSoundFileName, NULL);
Android framework开发全局系统属性设置与获取,布布扣,bubuko.com
Android framework开发全局系统属性设置与获取
标签:android style class blog code java
原文地址:http://blog.csdn.net/qq435757399/article/details/30270875