Code example for Preference

Methods: setOnPreferenceClickListener

0
            return; 
        } 
 
        mUiHandler.removeCallbacks(mUpdateCountdownSummaryRunnable);
        mContext.unregisterReceiver(mReceiver);
        mDiscoveryPreference.setOnPreferenceClickListener(null);
    } 
 
    public boolean onPreferenceClick(Preference preference) {
        // toggle discoverability 
        mDiscoverable = !mDiscoverable;
        setEnabled(mDiscoverable);
        return true; 
    } 
 
    private void setEnabled(boolean enable) {
        if (enable) {
            int timeout = getDiscoverableTimeout();
            long endTimestamp = System.currentTimeMillis() + timeout * 1000L;
            LocalBluetoothPreferences.persistDiscoverableEndTimestamp(mContext, endTimestamp);