List of usage examples for android.app Activity RESULT_OK
int RESULT_OK
To view the source code for android.app Activity RESULT_OK.
Click Source Link
From source file:br.liveo.searchliveo.SearchLiveo.java
public void resultVoice(int requestCode, int resultCode, Intent data) { if (requestCode == SearchLiveo.REQUEST_CODE_SPEECH_INPUT) { if (resultCode == Activity.RESULT_OK && null != data) { ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); mEdtSearch.setText(result.get(0)); }//from w w w .j ava 2 s . c o m } }
From source file:com.andrewshu.android.reddit.submit.SubmitLinkActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); switch (requestCode) { case Constants.ACTIVITY_PICK_SUBREDDIT: if (resultCode == Activity.RESULT_OK) { // Group 1: Subreddit. final Pattern REDDIT_PATH_PATTERN = Pattern.compile(Constants.REDDIT_PATH_PATTERN_STRING); Matcher redditContextMatcher = REDDIT_PATH_PATTERN.matcher(intent.getData().getPath()); if (redditContextMatcher.find()) { String newSubreddit = redditContextMatcher.group(1); final EditText linkSubreddit = (EditText) findViewById(R.id.submit_link_reddit); final EditText textSubreddit = (EditText) findViewById(R.id.submit_text_reddit); if (newSubreddit != null) { linkSubreddit.setText(newSubreddit); textSubreddit.setText(newSubreddit); } else { linkSubreddit.setText(""); textSubreddit.setText(""); }/*from ww w . j a va2 s . co m*/ } } break; default: break; } }
From source file:br.liveo.searchliveo.SearchCardLiveo.java
public void resultVoice(int requestCode, int resultCode, Intent data) { if (requestCode == SearchCardLiveo.REQUEST_CODE_SPEECH_INPUT) { if (resultCode == Activity.RESULT_OK && null != data) { ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); mEdtSearch.setText(result.get(0)); }/* ww w . j av a 2 s. c o m*/ } }
From source file:org.protocoderrunner.apprunner.api.PNetwork.java
public SimpleBT startBluetooth() { if (mBtStarted) { return simpleBT; }//from ww w . ja va 2s . c o m simpleBT = new SimpleBT(appRunnerActivity.get()); simpleBT.start(); (appRunnerActivity.get()).addBluetoothListener(new onBluetoothListener() { @Override public void onDeviceFound(String name, String macAddress, float strength) { } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { simpleBT.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case SimpleBT.REQUEST_ENABLE_BT: // When the request to enable Bluetooth returns if (resultCode == Activity.RESULT_OK) { //MLog.d(TAG, "enabling BT"); // Bluetooth is now enabled, so set up a Bluetooth session mBtStarted = true; simpleBT.startBtService(); // User did not enable Bluetooth or an error occurred } else { // MLog.d(TAG, "BT not enabled"); Toast.makeText(a.get().getApplicationContext(), "BT not enabled :(", Toast.LENGTH_SHORT) .show(); } } } }); WhatIsRunning.getInstance().add(simpleBT); return simpleBT; }
From source file:com.kjsaw.alcosys.ibacapp.IBAC.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { _inDialog = false;//from w ww .j a va2 s . co m switch (requestCode) { case REQUEST_CONNECT_DEVICE: // When DeviceListActivity returns with a device to connect _conversationArrayAdapter.clear(); if (resultCode == Activity.RESULT_OK) { // Get the device MAC address bluetoothMACAddress = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS); // Get the BLuetoothDevice object BluetoothDevice device = _bluetoothAdapter.getRemoteDevice(bluetoothMACAddress); unpairDevice(device); pairDevice(device); // Attempt to connect to the device _iBACservice.connect(device); } else if (resultCode == Constant.RESULT_ERROR_MORE_IBAC) { _conversationArrayAdapter.add(getResources().getString(R.string.error_more_ibac)); ShutdownAction shutdownAction = new ShutdownAction(_handler, 3, true); shutdownAction.Invoke(null); } else { if (ApplicationConstants.DebugMode) Log.d(TAG, "No devices found"); _conversationArrayAdapter.add(getResources().getString(R.string.none_found)); ShutdownAction shutdownAction = new ShutdownAction(_handler, 3, true); shutdownAction.Invoke(null); } break; case REQUEST_ENABLE_BT: if (resultCode == Activity.RESULT_OK) { _isConfiguringPhone = false; InitializeAllServices(); } else { // User did not enable Bluetooth or an error occured if (ApplicationConstants.DebugMode) Log.d(ApplicationConstants.ApplicationTag, "Bluetooth is not enabled"); _handler.obtainMessage(IBAC.ADD_MESSAGE, getResources().getString(R.string.bt_not_enabled_leaving)) .sendToTarget(); ShutdownAction shutdownAction = new ShutdownAction(_handler, 3, true); shutdownAction.Invoke(null); } break; case ApplicationConstants.CALIBRATION: switch (resultCode) { case ApplicationConstants.REQUEST_CALIBRATE: if (_iBACservice._messageProcessor.GetState() == MessageProcessorStates.NotConnected) { _handler.obtainMessage(CALIBRATION_ABORTED_NO_CONNECTION, null).sendToTarget(); } else { try { _iBACservice._messageProcessor.SendMessage(Messages.RequestCalibration); _handler.obtainMessage(CALIBRATING, null).sendToTarget(); } catch (Exception e) { Log.e(ApplicationConstants.ApplicationTag, "Failed to send calibration message: " + ExceptionHelper.GetTypeIfMessageEmpty(e)); } } break; case ApplicationConstants.ACTIVITY_ABORT: if (_iBACservice._messageProcessor.GetState() == MessageProcessorStates.NotConnected) { _handler.obtainMessage(CALIBRATION_ABORTED_NO_CONNECTION, null).sendToTarget(); } else { _handler.obtainMessage(CALIBRATION_ABORTED, null).sendToTarget(); } break; default: break; } break; // case REQUEST_ENABLE_GPS: // deviceLocation.runGPS(); // initBluetooth(); // break; default: break; } }
From source file:com.example.pyrkesa.shwc.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_ENABLE_BT) { if (resultCode == Activity.RESULT_OK) { connectToService();/*from www . jav a2 s . co m*/ } else { Toast.makeText(this, "Bluetooth not enabled", Toast.LENGTH_LONG).show(); getActionBar().setSubtitle("Bluetooth not enabled"); } } }
From source file:eu.dirtyharry.androidopsiadmin.Main.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == GET_QR && resultCode == RESULT_OK) { contents = data.getExtras().getString("la.droid.qr.result"); if (checkQR(contents)) { try { pc = (JSONObject) new JSONTokener(contents).nextValue(); hosttocheck = pc.getString("dns"); } catch (JSONException e) { e.printStackTrace();//www. j a va 2s .co m } final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait), String.format(getString(R.string.pd_checkifopsiclientexists), hosttocheck), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { if (hostexistsinopsi && doit.equals("true")) { if (customtags) { Intent i = new Intent(Main.this, ShowBarcodeData.class); Bundle b = new Bundle(); b.putString("qrdata", contents); i.putExtras(b); startActivity(i); } else { Intent i = new Intent(Main.this, ShowOpsiClientOptions.class); Bundle b = new Bundle(); b.putString("qrdata", contents); i.putExtras(b); startActivity(i); } } else if (!hostexistsinopsi) { new Functions().msgBox(Main.this, getString(R.string.gen_title_error), String.format(getString(R.string.general_noopsihost), hosttocheck), false); } else { Toast.makeText(Main.this, String.format(getString(R.string.to_servernotrechable), serverip), Toast.LENGTH_LONG).show(); } dialog.dismiss(); } }; Thread checkUpdate = new Thread() { public void run() { Looper.prepare(); if (eu.dirtyharry.androidopsiadmin.Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) { doit = "true"; if (eu.dirtyharry.androidopsiadmin.Networking.checkIfHostExistsInOpsi(hosttocheck, serverip, serverport, serverusername, serverpasswd)) { hostexistsinopsi = true; } else { hostexistsinopsi = false; } } else { doit = "serverdown"; } handler.sendEmptyMessage(0); } }; checkUpdate.start(); } else { new Functions().msgBox(Main.this, getString(R.string.gen_title_error), getString(R.string.at_novalidqr), false); } } else if (requestCode == GET_OPSI_CLIENT_REQUEST && resultCode == Activity.RESULT_OK) { if (data.getStringExtra("message").equals("refresh")) { getOpsiClientsTask(); } // } else if (requestCode == SHOW_OPSI_DEPOT_REQUEST // && resultCode == Activity.RESULT_OK) { // resultconfignames = data.getExtras().getStringArrayList( // "choosenones"); // resultconfigvalues = data.getExtras().getStringArrayList( // "choosenonesvalues"); // event_opsisenddepotconfigchanges(); } }
From source file:com.todoroo.astrid.taskrabbit.TaskRabbitActivity.java
@SuppressWarnings("nls") @Override//from ww w. ja v a 2s . c om public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_TASK_RABBIT_OAUTH && resultCode == Activity.RESULT_OK) { String result = data.getStringExtra(TaskRabbitOAuthLoginActivity.DATA_RESPONSE); String key = "access_token="; //$NON-NLS-1$ if (result.contains(key)) { try { result = result.substring(result.indexOf(key) + key.length()); Preferences.setString(TASK_RABBIT_TOKEN, result); String url = String.format("%s?oauth_token=%s&client_application=%s", taskRabbitURL("account"), Preferences.getStringValue(TASK_RABBIT_TOKEN), TASK_RABBIT_CLIENT_APPLICATION_ID); String response = restClient.get(url); saveUserInfo(response);//; } catch (Exception e) { e.printStackTrace(); } return; } } else if (requestCode == REQUEST_CODE_ENABLE_GPS) { loadLocation(); } else { for (TaskRabbitSetListener set : controls) { if (set instanceof ActivityResultSetListener) { if (((ActivityResultSetListener) set).activityResult(requestCode, resultCode, data)) return; } } } }
From source file:it.feio.android.omninotes.SettingsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case SPRINGPAD_IMPORT: Uri filesUri = intent.getData(); String path = FileHelper.getPath(getActivity(), filesUri); // An IntentService will be launched to accomplish the import task Intent service = new Intent(getActivity(), DataBackupIntentService.class); service.setAction(DataBackupIntentService.ACTION_DATA_IMPORT_SPRINGPAD); service.putExtra(DataBackupIntentService.EXTRA_SPRINGPAD_BACKUP, path); getActivity().startService(service); break; case RINGTONE_REQUEST_CODE: Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String notificationSound = uri == null ? null : uri.toString(); prefs.edit().putString("settings_notification_ringtone", notificationSound).apply(); break; }/*from w ww .j a v a 2s. c o m*/ } }
From source file:cc.mintcoin.wallet.ui.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;/* www .jav a2 s .c om*/ updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); //Emptying a wallet with less than 2 MINT can't be possible due to min fee 2 MINT of such a tx. /* if (amount.compareTo(BigInteger.valueOf(200000000)) < 0 && sendRequest.emptyWallet) { AlertDialog.Builder bld = new AlertDialog.Builder(activity); bld.setTitle(R.string.send_coins_error_msg); bld.setMessage(R.string.send_coins_error_desc); bld.setNeutralButton(activity.getResources().getString(android.R.string.ok), null); bld.setCancelable(false); bld.create().show(); state = State.FAILED; updateView(); return; }*/ new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(paymentIntent.standard, payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, paymentIntent.getBluetoothMac()).send(paymentIntent.standard, payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final BigInteger estimated = wallet.getBalance(BalanceType.ESTIMATED); final BigInteger available = wallet.getBalance(BalanceType.AVAILABLE); final BigInteger pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(String.format(getString(R.string.send_coins_fragment_insufficient_money_msg1), btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append(getString(R.string.send_coins_fragment_pending, GenericUtils.formatValue(pending, btcPrecision, btcShift))).append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure() { state = State.FAILED; updateView(); activity.longToast(R.string.send_coins_error_msg); } }.sendCoinsOffline(sendRequest); // send asynchronously }