List of usage examples for android.os Message getData
public Bundle getData()
From source file:com.samsung.smcl.example.helloworldprovider.backend.HelloWorldProviderService.java
public void handleMessage(Message msg) { Bundle data;// w ww . j av a 2s . c om switch (msg.what) { case MSG_NOTIFICATION: Utility.logDebug(TAG, "Received notification message"); data = msg.getData(); if (data == null) { Utility.logWarning(TAG, "Received notification bundle is null"); return; } NotificationModel notification = new NotificationModel(data); Utility.logDebug(TAG, "Sending accessory notification to Gear"); NotificationUtility.sendNotificationToGear(TAG, this, notification, HELLO_WORLD_LINKED_PACKAGE_NAME); break; case MSG_TO_HELLOWORLDPROVIDERSERVICE: Utility.logDebug(TAG, "MSG_TO_HELLOWORLDPROVIDERSERVICE"); Utility.logDebug(TAG, "Send message to consumer"); data = msg.getData(); String str = data.getString(BUNDLE_DATA); sendToConsumer(str); break; case MSG_REGISTER_CLIENT: Utility.logDebug(TAG, "MSG_REGISTER_CLIENT"); mHelloWorldMessenger = msg.replyTo; mBound = true; if (myConnection != null) { JSONObject jObj2 = createConnectionStatusJSONObject(true); sendToHelloWorldService(jObj2.toString()); } break; case MSG_UNREGISTER_CLIENT: Utility.logDebug(TAG, "MSG_UNREGISTER_CLIENT"); mHelloWorldMessenger = null; mBound = false; break; default: Utility.logError(TAG, "Unsupported message"); break; } }
From source file:org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper.java
public void cryptoOperation(final CryptoInputParcel cryptoInput) { FragmentActivity activity = mUseFragment ? mFragment.getActivity() : mActivity; T operationInput = mCallback.createOperationInput(); if (operationInput == null) { return;//w w w. j a v a 2 s .c om } // Send all information needed to service to edit key in other thread Intent intent = new Intent(activity, KeychainService.class); intent.putExtra(KeychainService.EXTRA_OPERATION_INPUT, operationInput); intent.putExtra(KeychainService.EXTRA_CRYPTO_INPUT, cryptoInput); ServiceProgressHandler saveHandler = new ServiceProgressHandler(activity) { @Override public void handleMessage(Message message) { // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == MessageStatus.OKAY.ordinal()) { // get returned data bundle Bundle returnData = message.getData(); if (returnData == null) { return; } final OperationResult result = returnData.getParcelable(OperationResult.EXTRA_RESULT); onHandleResult(result); } } @Override protected void onSetProgress(String msg, int progress, int max) { // allow handling of progress in fragment, or delegate upwards if (!mCallback.onCryptoSetProgress(msg, progress, max)) { super.onSetProgress(msg, progress, max); } } }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(saveHandler); intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger); if (mProgressMessageResource != null) { saveHandler.showProgressDialog(activity.getString(mProgressMessageResource), ProgressDialog.STYLE_HORIZONTAL, mCancellable); } activity.startService(intent); }
From source file:com.zia.freshdocs.widget.CMISAdapter.java
/** * Send the content using a built-in Android activity which can handle the content type. * @param position//w ww . j ava 2 s . c o m */ public void shareContent(int position) { final NodeRef ref = getItem(position); downloadContent(ref, new Handler() { public void handleMessage(Message msg) { Context context = getContext(); boolean done = msg.getData().getBoolean("done"); if (done) { dismissProgressDlg(); File file = (File) _dlThread.getResult(); if (file != null) { Resources res = context.getResources(); Uri uri = Uri.fromFile(file); Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_STREAM, uri); emailIntent.putExtra(Intent.EXTRA_SUBJECT, ref.getName()); emailIntent.putExtra(Intent.EXTRA_TEXT, res.getString(R.string.email_text)); emailIntent.setType(ref.getContentType()); try { context.startActivity( Intent.createChooser(emailIntent, res.getString(R.string.email_title))); } catch (ActivityNotFoundException e) { String text = "No suitable applications registered to send " + ref.getContentType(); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } } } else { int value = msg.getData().getInt("progress"); if (value > 0) { _progressDlg.setProgress(value); } } } }); }
From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvSubkeysFragment.java
private void editSubkeyExpiry(final int position) { final long keyId = mSubkeysAdapter.getKeyId(position); final Long creationDate = mSubkeysAdapter.getCreationDate(position); final Long expiryDate = mSubkeysAdapter.getExpiryDate(position); Handler returnHandler = new Handler() { @Override/* w w w.ja v a2s. co m*/ public void handleMessage(Message message) { switch (message.what) { case EditSubkeyExpiryDialogFragment.MESSAGE_NEW_EXPIRY: mEditModeSaveKeyringParcel.getOrCreateSubkeyChange(keyId).mExpiry = (Long) message.getData() .getSerializable(EditSubkeyExpiryDialogFragment.MESSAGE_DATA_EXPIRY); break; } getLoaderManager().getLoader(LOADER_ID_SUBKEYS).forceLoad(); } }; // Create a new Messenger for the communication back final Messenger messenger = new Messenger(returnHandler); DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { public void run() { EditSubkeyExpiryDialogFragment dialogFragment = EditSubkeyExpiryDialogFragment .newInstance(messenger, creationDate, expiryDate); dialogFragment.show(getActivity().getSupportFragmentManager(), "editSubkeyExpiryDialog"); } }); }
From source file:com.t2.biofeedback.BioFeedbackService.java
void performServiceCommand(Message msg) { byte[] payload = msg.getData().getByteArray("EXTRA_MESSAGE_PAYLOAD"); if (payload == null) return;//w w w . jav a2s.c o m if (deviceManager == null) { Log.e(TAG, "NEW no device manager"); return; } byte sensor; byte command; byte[] btAddress = new byte[6]; String btAddressString; if (payload.length == 7 + 255) { // See ShimmerNonSpineSetupSensor_codec for coding format command = payload[0]; try { for (int i = 0; i < 6; i++) { btAddress[i] = payload[i + 1]; } btAddressString = Util.getBtStringAddress(btAddress); } catch (IndexOutOfBoundsException e) { Log.e(TAG, e.toString()); btAddressString = ""; } if (command == COMMAND_ENABLED) { this.deviceManager.setDeviceEnabled(btAddressString, true); } else { if (command == COMMAND_DISABLED) { this.deviceManager.setDeviceEnabled(btAddressString, false); } else { Log.e(TAG, "performServiceCommand() Command not recognized"); } } } // Now send the updated device list to the activity so it can update it's listview sendDeviceList(); }
From source file:com.t2.biofeedback.BioFeedbackService.java
void performSetupSensor(Message msg) { byte[] payload = msg.getData().getByteArray("EXTRA_MESSAGE_PAYLOAD"); if (payload == null) return;// w w w. j a v a 2 s . com if (deviceManager == null) { Log.e(TAG, "NEW no device manager"); return; } byte sensor; byte command; byte[] btAddress = new byte[6]; String btAddressString; if (payload.length == 8 + 255) { // See ShimmerNonSpineSetupSensor_codec for coding format sensor = payload[0]; command = payload[1]; try { for (int i = 0; i < 6; i++) { btAddress[i] = payload[i + 2]; } btAddressString = Util.getBtStringAddress(btAddress); } catch (IndexOutOfBoundsException e) { Log.e(TAG, e.toString()); btAddressString = ""; } BioFeedbackDevice[] enabledDevices = deviceManager.getEnabledDevices(); for (BioFeedbackDevice d : enabledDevices) { if (d.isBonded() && d.isConencted()) { if (d instanceof ShimmerDevice) { String s = d.getAddress(); if (d.getAddress().equalsIgnoreCase(btAddressString)) { Log.i(TAG, "Address = " + s); ShimmerDevice dev = (ShimmerDevice) d; dev.setup(sensor, command); } } } } } }
From source file:com.app.jdy.ui.CashAdvanceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cashadvance); initView();// w w w . ja v a2 s .c om // ???? btnConfirmReceiver = new BtnConfirmReceiver(); IntentFilter intentFilter = new IntentFilter("org.jdy.action.WITHDCASH_BROADCAST"); CashAdvanceActivity.this.registerReceiver(btnConfirmReceiver, intentFilter); handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { // ????? case 1: Bundle bundle = msg.getData(); canWithdCash = bundle.getString("canWithdCash"); String bankName = bundle.getString("bankName"); bankCode1 = bundle.getString("bankCode1"); String bankCode = bundle.getString("bankCode"); if (StringUtils.isNullOrEmpty(bankName)) { bankName = "?"; } // ? textView4.setText(bankName); // ? textView3.setText("(" + bankCode + ")"); if (StringUtils.isNullOrEmpty(bankCode)) { textView3.setText(""); } // ?????? textView2.setText(canWithdCash); // ????? editText.setText(canWithdCash); break; // ????? case 2: if (withdrawCashDialog != null) { withdrawCashDialog.dismiss(); } break; // ??????? case 3: Toast.makeText(CashAdvanceActivity.this, "??? " + withdrawresult + " ???", Toast.LENGTH_LONG) .show(); editText.setText(""); if (withdrawCashDialog != null) { withdrawCashDialog.dismiss(); } finish(); break; // ?????? case 0x110: Toast.makeText(CashAdvanceActivity.this, "??", Toast.LENGTH_SHORT).show(); if (withdrawCashDialog != null) { withdrawCashDialog.dismiss(); } break; // ???????????? case 4: Toast.makeText(CashAdvanceActivity.this, Constants.NO_INTENT_TIPS, Toast.LENGTH_LONG).show(); if (withdrawCashDialog != null) { withdrawCashDialog.dismiss(); } break; default: break; } } }; addEvents(); }
From source file:com.fox.myappstore.MainActivity.java
@Override public void handleMessage(Message msg) { switch (msg.what) { case EVENT_GET_RECOMMENDED_APPS: { Bundle bundle = msg.getData(); if (bundle.getBoolean(HttpRequestImpl.IS_SUCCESSFUL)) { setupRecommendedFeed(bundle); }// ww w . j a v a 2 s. c o m break; } case EVENT_GET_APPS_LIST: { Bundle bundle = msg.getData(); if (bundle.getBoolean(HttpRequestImpl.IS_SUCCESSFUL)) { setupAppListFeed(bundle); } break; } case EVENT_QUERY_APPS_LIST: { int paginationEndPosition = paginationStartPosition + 10; List<FreeAppModel> models; if (appList.size() > 0) { Log.i(TAG, "using appList"); models = appList.subList(paginationStartPosition, paginationEndPosition); } else { Log.i(TAG, "using cache"); models = cachedAppList.subList(paginationStartPosition, paginationEndPosition); } myBaseAdapter.updateAppListData(models); myBaseAdapter.setLoading(false); myBaseAdapter.notifyDataSetChanged(); paginationStartPosition = paginationEndPosition; myBaseAdapter.onLoadFinished(); break; } case EVENT_QUERY_APP_DETAIL: { Bundle bundle = msg.getData(); if (bundle.getBoolean(HttpRequestImpl.IS_SUCCESSFUL)) { setupRatingModules(bundle); updateAppListAdapter(appList); break; } break; } default: break; } }
From source file:cn.sharesdk.analysis.server.ServiceHelper.java
@Override public boolean handleMessage(Message msg) { if (!Thread.currentThread().isInterrupted()) { // ?/* ww w. j a va 2s .c o m*/ switch (msg.what) { case UPLOAD_LOG: uploadAllLog(); break; case SAVE_SEND_LOG: Bundle bundle = msg.getData(); String jsonString = bundle.getString("value"); // Ln.i("insert msg ==>>", jsonString); sendIsAppExitMsg(); MessageUtils.insertMsg(context, bundle.getString("action"), jsonString); uploadAllLog(); break; case EXIT_APP: // exit app when the app in the background 15s if (appBackRunning) { return true; } appBackRunning = true; appExitCount = 0; new Thread(new Runnable() { @Override public void run() { while (appBackRunning) { try { if (isAppExit()) { appExitCount++; Ln.i("exit app after background seconds ==>>", appExitCount + ""); if (appExitCount == 15) { preference.setAppExitDate(); Ln.i("exit app ==>>", " upload all log "); MessageUtils.insertMsg(context, MessageUtils.EXIT_DATA, getExitAppString()); sendUploadLogMsg(); } else if (appExitCount >= 30) { appBackRunning = false; } } else { appExitCount = 0; } Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } } } }).start(); break; } } return false; }
From source file:com.nextgis.firereporter.SettingsSupport.java
public SettingsSupport(Context context, PreferenceScreen screen) { this.screen = screen; this.context = context; // Load the preferences from an XML resource //addPreferencesFromResource(R.xml.preferences); mSendDataIntervalPref = (ListPreference) screen.findPreference(SettingsActivity.KEY_PREF_INTERVAL); if (mSendDataIntervalPref != null) { int index = mSendDataIntervalPref.findIndexOfValue(mSendDataIntervalPref.getValue()); if (index >= 0) { mSendDataIntervalPref.setSummary(mSendDataIntervalPref.getEntries()[index]); } else {/*from w ww .ja v a 2 s . com*/ mSendDataIntervalPref.setSummary((String) mSendDataIntervalPref.getValue()); } } mSaveBattPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_SERVICE_BATT_SAVE); if (mSaveBattPref != null) mSaveBattPref.setSummary(mSaveBattPref.isChecked() ? R.string.stOn : R.string.stOff); mNotifyLEDPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_NOTIFY_LED); if (mNotifyLEDPref != null) mNotifyLEDPref.setSummary(mNotifyLEDPref.isChecked() ? R.string.stOn : R.string.stOff); mPlaySoundPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_NOTIFY_SOUND); if (mPlaySoundPref != null) mPlaySoundPref.setSummary(mPlaySoundPref.isChecked() ? R.string.stOn : R.string.stOff); mVibroPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_NOTIFY_VIBRO); if (mVibroPref != null) mVibroPref.setSummary(mVibroPref.isChecked() ? R.string.stOn : R.string.stOff); mRowCountPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_ROW_COUNT); if (mRowCountPref != null) mRowCountPref.setSummary((String) mRowCountPref.getText()); mFireSearchRadiusPref = (EditTextPreference) screen .findPreference(SettingsActivity.KEY_PREF_FIRE_SEARCH_RADIUS); if (mFireSearchRadiusPref != null) mFireSearchRadiusPref .setSummary((String) mFireSearchRadiusPref.getText() + " " + context.getString(R.string.km)); mDayIntervalPref = (ListPreference) screen.findPreference(SettingsActivity.KEY_PREF_SEARCH_DAY_INTERVAL); if (mDayIntervalPref != null) { int index = mDayIntervalPref.findIndexOfValue(mDayIntervalPref.getValue()); if (index >= 0) { mDayIntervalPref.setSummary(mDayIntervalPref.getEntries()[index]); } else { mDayIntervalPref.setSummary((String) mDayIntervalPref.getValue()); } } mSearchCurrentDatePref = (CheckBoxPreference) screen .findPreference(SettingsActivity.KEY_PREF_SEARCH_CURR_DAY); if (mSearchCurrentDatePref != null) mSearchCurrentDatePref.setSummary(mSearchCurrentDatePref.isChecked() ? R.string.stSearchCurrentDayOn : R.string.stSearchCurrentDayOff); mNasaServerPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_NASA); if (mNasaServerPref != null) mNasaServerPref.setSummary((String) mNasaServerPref.getText()); mNasaServerUserPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_NASA_USER); if (mNasaServerUserPref != null) mNasaServerUserPref.setSummary((String) mNasaServerUserPref.getText()); mUserServerPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_USER); if (mUserServerPref != null) mUserServerPref.setSummary((String) mUserServerPref.getText()); mUserServerUserPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_USER_USER); if (mUserServerUserPref != null) mUserServerUserPref.setSummary((String) mUserServerUserPref.getText()); mScanServerUserPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_SCAN_USER); if (mScanServerUserPref != null) mScanServerUserPref.setSummary((String) mScanServerUserPref.getText()); mNasaServerPassPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_NASA_PASS); mUserServerPassPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_USER_PASS); mScanServerPassPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_SCAN_PASS); final Preference checkNasaConnPref = (Preference) screen .findPreference(SettingsActivity.KEY_PREF_SRV_NASA_CHECK_CONN); final Preference checkUserConnPref = (Preference) screen .findPreference(SettingsActivity.KEY_PREF_SRV_USER_CHECK_CONN); final Preference checkScanConnPref = (Preference) screen .findPreference(SettingsActivity.KEY_PREF_SRV_SCAN_CHECK_CONN); mReturnHandler = new Handler() { @SuppressLint("NewApi") public void handleMessage(Message msg) { Bundle resultData = msg.getData(); boolean bHaveErr = resultData.getBoolean(GetFiresService.ERROR); int nType = resultData.getInt(GetFiresService.SOURCE); if (bHaveErr) { Toast.makeText(SettingsSupport.this.context, resultData.getString(GetFiresService.ERR_MSG), Toast.LENGTH_LONG).show(); if (nType == 1) {//user checkUserConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkUserConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else if (nType == 2) {//nasa checkNasaConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkNasaConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else if (nType == 3) {//scanex checkScanConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkScanConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } } else { String sData = resultData.getString(GetFiresService.JSON); if (nType == 1) {//user JSONObject jsonMainObject; try { jsonMainObject = new JSONObject(sData); if (jsonMainObject.getBoolean("error")) { String sMsg = jsonMainObject.getString("msg"); Toast.makeText(SettingsSupport.this.context, sMsg, Toast.LENGTH_LONG).show(); checkUserConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkUserConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else { checkUserConnPref.setSummary(R.string.stConnectionSucceeded); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkUserConnPref.setIcon(R.drawable.ic_navigation_accept); } } catch (JSONException e) { Toast.makeText(SettingsSupport.this.context, e.toString(), Toast.LENGTH_LONG).show(); e.printStackTrace(); checkUserConnPref.setSummary(R.string.sCheckDBConnSummary); } } else if (nType == 2) {//nasa JSONObject jsonMainObject; try { jsonMainObject = new JSONObject(sData); if (jsonMainObject.getBoolean("error")) { String sMsg = jsonMainObject.getString("msg"); Toast.makeText(SettingsSupport.this.context, sMsg, Toast.LENGTH_LONG).show(); checkNasaConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkNasaConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else { checkNasaConnPref.setSummary(R.string.stConnectionSucceeded); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkNasaConnPref.setIcon(R.drawable.ic_navigation_accept); } } catch (JSONException e) { Toast.makeText(SettingsSupport.this.context, e.toString(), Toast.LENGTH_LONG).show(); e.printStackTrace(); checkNasaConnPref.setSummary(R.string.sCheckDBConnSummary); } } else if (nType == 3) {//scanex if (sData.length() == 0) { String sMsg = "Connect failed"; Toast.makeText(SettingsSupport.this.context, sMsg, Toast.LENGTH_LONG).show(); checkScanConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkScanConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else { checkScanConnPref.setSummary(R.string.stConnectionSucceeded); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkScanConnPref.setIcon(R.drawable.ic_navigation_accept); new HttpGetter(SettingsSupport.this.context, 4, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true).execute( "http://fires.kosmosnimki.ru/SAPI/Account/Get/?CallBackName=" + GetFiresService.USER_ID, sData); } } else if (nType == 4) {//scanex detailes try { String sSubData = GetFiresService.removeJsonT(sData); JSONObject rootobj = new JSONObject(sSubData); String sStatus = rootobj.getString("Status"); if (sStatus.equals("OK")) { JSONObject resobj = rootobj.getJSONObject("Result"); String sName = ""; if (!resobj.isNull("FullName")) sName = resobj.getString("FullName"); String sPhone = ""; if (!resobj.isNull("Phone")) sPhone = resobj.getString("Phone"); //add properties if (sPhone.length() > 0) { Preference PhonePref = new Preference(SettingsSupport.this.context); PhonePref.setTitle(R.string.stScanexServerUserPhone); PhonePref.setSummary(sPhone); PhonePref.setOrder(2); SettingsSupport.this.screen.addPreference(PhonePref); } if (sName.length() > 0) { Preference NamePref = new Preference(SettingsSupport.this.context); NamePref.setTitle(R.string.stScanexServerUserFullName); NamePref.setSummary(sName); NamePref.setOrder(2); SettingsSupport.this.screen.addPreference(NamePref); } } else { Toast.makeText(SettingsSupport.this.context, rootobj.getString("ErrorInfo"), Toast.LENGTH_LONG).show(); } } catch (JSONException e) { Toast.makeText(SettingsSupport.this.context, e.toString(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } } } }; }; if (checkNasaConnPref != null) checkNasaConnPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { String sURL = mNasaServerPref.getText() + "?function=test_conn_nasa&user=" + mNasaServerUserPref.getText() + "&pass=" + mNasaServerPassPref.getText(); new HttpGetter(SettingsSupport.this.context, 2, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true) .execute(sURL); return true; } }); if (checkUserConnPref != null) checkUserConnPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { String sURL = mUserServerPref.getText() + "?function=test_conn_user&user=" + mUserServerUserPref.getText() + "&pass=" + mUserServerPassPref.getText(); new HttpGetter(SettingsSupport.this.context, 1, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true) .execute(sURL); return true; } }); if (checkScanConnPref != null) checkScanConnPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { //String sURL = mUserServerPref.getText() + "?function=test_conn_nasa&user=" + mUserServerUserPref.getText() + "&pass=" + mUserServerPassPref.getText(); new ScanexHttpLogin(SettingsSupport.this.context, 3, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true) .execute(mScanServerUserPref.getText(), mScanServerPassPref.getText()); return true; } }); }