List of usage examples for android.preference Preference isEnabled
public boolean isEnabled()
From source file:net.sf.aria2.MainActivity.java
private boolean changeAriaServiceState(Preference p) { if (p.isEnabled()) { // it looks unsightly when current session overlaps with previous one... ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancel(R.id.nf_status); pref.setEnabled(false);//from ww w .j av a 2 s . c o m uiThreadHandler.postDelayed(() -> pref.setEnabled(true), 4000); if (pref.isChecked()) { try { serviceLink.askToStop(); } catch (RemoteException e) { // likely service process dying during the call // let's hope, that onSerivceDisconnected will fix it for us e.printStackTrace(); setPrefEnabled(false); } } else { final Intent intent; try { intent = new ConfigBuilder(this).constructServiceCommand(new Intent(sericeMoniker)) .putExtra(Config.EXTRA_INTERACTIVE, true); if (startService(intent) == null) setPrefEnabled(false); } catch (Exception e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); } } } return true; }