use of android.content.SharedPreferences in project android-sms-relay by nyaruka.
the class AlarmListener method scheduleAlarms.
public void scheduleAlarms(AlarmManager mgr, PendingIntent pi, Context ctxt) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctxt);
boolean process = prefs.getBoolean("process_incoming", false) || prefs.getBoolean("process_outgoing", false);
if (m_interval == 0) {
String updateInterval = prefs.getString("update_interval", "" + FREQUENCY);
m_interval = Long.parseLong(updateInterval);
}
if (m_interval > 0 && process) {
mgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + m_interval, pi);
}
}
use of android.content.SharedPreferences in project android-sms-relay by nyaruka.
the class AndroidRelay method onCreate.
@Override
public void onCreate() {
super.onCreate();
// migrate old preferences
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.contains("rapidsms_hostname")) {
Editor editor = prefs.edit();
editor.putString("router_hostname", prefs.getString("rapidsms_hostname", null));
editor.putString("router_password", prefs.getString("rapidsms_password", null));
editor.putString("router_backend", prefs.getString("rapidsms_backend", null));
editor.remove("rapidsms_hostname");
editor.remove("rapidsms_password");
editor.remove("rapidsms_backend");
editor.commit();
}
m_helper = new TextMessageHelper(this);
m_phoneState = new PhoneState();
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
telephonyManager.listen(m_phoneState, PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
use of android.content.SharedPreferences in project android-sms-relay by nyaruka.
the class CheckService method restoreDefaultNetwork.
/**
* Restores our WIFI/DATA state to whatever is in our preference file. No-op if
* our current state is the same as our preferred state.
*/
public void restoreDefaultNetwork() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean isWifiPreferred = Integer.parseInt(prefs.getString("pref_net", "0")) % 2 == 0;
WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifi.isWifiEnabled() != isWifiPreferred) {
// toggle back to the preferred network
wifi.setWifiEnabled(isWifiPreferred);
try {
Thread.sleep(30000);
} catch (Throwable t) {
}
}
}
use of android.content.SharedPreferences in project platform_frameworks_base by android.
the class SampleTrustAgent method setIsManagingTrust.
public static void setIsManagingTrust(Context context, boolean enabled) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
sharedPreferences.edit().putBoolean(PREFERENCE_MANAGING_TRUST, enabled).apply();
}
use of android.content.SharedPreferences in project platform_frameworks_base by android.
the class SampleTrustAgent method setReportDeviceLocked.
public static void setReportDeviceLocked(Context context, boolean enabled) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
sharedPreferences.edit().putBoolean(PREFERENCE_REPORT_DEVICE_LOCKED, enabled).apply();
}
Aggregations