Search in sources :

Example 61 with SharedPreferences

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);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 62 with SharedPreferences

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);
}
Also used : SharedPreferences(android.content.SharedPreferences) TelephonyManager(android.telephony.TelephonyManager) Editor(android.content.SharedPreferences.Editor) TextMessageHelper(com.nyaruka.androidrelay.data.TextMessageHelper)

Example 63 with SharedPreferences

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) {
        }
    }
}
Also used : WifiManager(android.net.wifi.WifiManager) SharedPreferences(android.content.SharedPreferences)

Example 64 with SharedPreferences

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();
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 65 with SharedPreferences

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();
}
Also used : SharedPreferences(android.content.SharedPreferences)

Aggregations

SharedPreferences (android.content.SharedPreferences)1762 Intent (android.content.Intent)221 View (android.view.View)110 Editor (android.content.SharedPreferences.Editor)100 TextView (android.widget.TextView)74 ArrayList (java.util.ArrayList)67 Context (android.content.Context)59 PendingIntent (android.app.PendingIntent)57 File (java.io.File)57 IOException (java.io.IOException)56 Bundle (android.os.Bundle)45 JSONException (org.json.JSONException)41 JSONObject (org.json.JSONObject)41 DialogInterface (android.content.DialogInterface)37 AdapterView (android.widget.AdapterView)34 ImageView (android.widget.ImageView)34 ListView (android.widget.ListView)34 SuppressLint (android.annotation.SuppressLint)33 JSONArray (run.wallet.common.json.JSONArray)33 ComponentName (android.content.ComponentName)31