例:String osName = System.getProperty("os.name")
System的Property属性很类似Android的sharedpreferences,都可以用来保存参数值。注意几点:
1.在某个APP中setProperty的值,在其他APP中getProperty获取不到(大概由于Android中每个APP都是一个独立的Dalvik);
2.在某个APP中setProperty的值,即使退出后也仍然存在,不经卸载直接重装也仍会存在,除非卸
掉
/** @hide */
public static final void setHttpProxySystemProperty(String host, String port, String exclList,
Uri pacFileUrl) {
if (exclList != null) exclList = exclList.replace(",", "|");
if (false) Log.d(TAG, "setHttpProxySystemProperty :"+host+":"+port+" - "+exclList);
if (host != null) {
System.setProperty("http.proxyHost", host);
System.setProperty("https.proxyHost", host);
} else {
System.clearProperty("http.proxyHost");
System.clearProperty("https.proxyHost");
}
if (port != null) {
System.setProperty("http.proxyPort", port);
System.setProperty("https.proxyPort", port);
} else {
System.clearProperty("http.proxyPort");
System.clearProperty("https.proxyPort");
}
if (exclList != null) {
System.setProperty("http.nonProxyHosts", exclList);
System.setProperty("https.nonProxyHosts", exclList);
} else {
System.clearProperty("http.nonProxyHosts");
System.clearProperty("https.nonProxyHosts");
}
if (!Uri.EMPTY.equals(pacFileUrl)) {
ProxySelector.setDefault(new PacProxySelector());
} else {
ProxySelector.setDefault(sDefaultProxySelector);
}
}
Android HttpProxy 工作原理(上) - 简书 (jianshu.com)
Android中使用System的setProperty()和getProperty()方法_android setproperty-CSDN博客