Back to project page AndroidWifiServer.
The source code is released under:
Apache License
If you think the Android project AndroidWifiServer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package jp.maju.wifiserver.twitter; //w w w . j a v a 2 s.c om import java.io.Serializable; import jp.maju.wifiserver.util.PreferenceUtil; import android.app.Application; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; public class ProxyWrapper implements Serializable { private static final String KEY_SSID = "keyProxySSID"; private static final String KEY_HOST = "keyProxyHost"; private static final String KEY_PORT = "keyProxyPort"; private static final String KEY_USERNAME = "keyProxyUsername"; private static final String KEY_PASSWORD = "keyProxyPassword"; public String host; public int port; public String user; public String pass; public String ssid; public ProxyWrapper(String host, int port, String user, String pass) { this.host = host; this.port = port; this.user = user; this.pass = pass; } public void setSSID(String ssid) { this.ssid = ssid; } public static boolean equals(ProxyWrapper source, ProxyWrapper target) { if (source == null && target == null) { return true; } else if (source == null || target == null) { return false; } else { if (source.ssid.equals(target.ssid)) { return true; } else { return false; } } } public static ProxyWrapper getRegisteredProxy(Application app, String ssid) { SharedPreferences pref = PreferenceUtil.getPreference(app); if (!pref.getBoolean(KEY_SSID + ssid, false)) { return null; } String host = pref.getString(KEY_HOST + ssid, null); int port = pref.getInt(KEY_PORT + ssid, 0); String username = pref.getString(KEY_USERNAME + ssid, null); String password = pref.getString(KEY_PASSWORD + ssid, null); return new ProxyWrapper(host, port, username, password); } public static void registerProxy(Application app, String ssid, String host, int port, String username, String password) { Editor e = PreferenceUtil.getPreference(app).edit(); e.putBoolean(KEY_SSID + ssid, true); e.putString(KEY_HOST + ssid, host); e.putInt(KEY_PORT + ssid, port); e.putString(KEY_USERNAME + ssid, username); e.putString(KEY_PASSWORD + ssid, password); e.commit(); } }