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:eu.operando.operandoapp.OperandoProxyStatus.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == Activity.RESULT_OK) { startProxyService();/* w ww . j a va 2s. c om*/ } else { //super.onActivityResult(requestCode, resultCode, data); if (mainContext.getAuthority().aliasFile(BouncyCastleSslEngineSource.KEY_STORE_FILE_EXTENSION) .exists()) { mainContext.getAuthority().aliasFile(BouncyCastleSslEngineSource.KEY_STORE_FILE_EXTENSION) .delete(); } } } }
From source file:com.example.cuisoap.agrimac.homePage.machineDetail.machineInfoFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri uri = data.getData();/* ww w . j a v a 2 s .co m*/ Log.e("uri", uri.toString()); ContentResolver cr = context.getContentResolver(); try { Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri)); bitmap = ImageUtils.comp(bitmap); switch (requestCode) { case 1: license_uri1 = uri; license_pic1.setImageBitmap(bitmap); license_pic1.setVisibility(View.VISIBLE); license1.setVisibility(View.GONE); license_pic1.setOnClickListener(myOnClickListener); machineDetailData.machine_license_filepath1 = ImageUtils.saveMyBitmap(bitmap, null); break; case 2: license_uri2 = uri; license_pic2.setImageBitmap(bitmap); license_pic2.setVisibility(View.VISIBLE); license2.setVisibility(View.GONE); license_pic2.setOnClickListener(myOnClickListener); machineDetailData.machine_license_filepath2 = ImageUtils.saveMyBitmap(bitmap, null); break; } } catch (FileNotFoundException e) { Log.e("Exception", e.getMessage(), e); } } else { Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.example.android.BluetoothChat.BluetoothChat.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (D)/* w w w . ja v a 2s . c om*/ Log.d(TAG, "onActivityResult " + resultCode); switch (requestCode) { case REQUEST_CONNECT_DEVICE_SECURE: // When DeviceListActivity returns with a device to connect if (resultCode == Activity.RESULT_OK) { connectDevice(data, true); } break; case REQUEST_CONNECT_DEVICE_INSECURE: // When DeviceListActivity returns with a device to connect if (resultCode == Activity.RESULT_OK) { connectDevice(data, false); } break; case REQUEST_ENABLE_BT: // When the request to enable Bluetooth returns if (resultCode == Activity.RESULT_OK) { // Bluetooth is now enabled, so set up a chat session setupChat(); } else { // User did not enable Bluetooth or an error occurred Log.d(TAG, "BT not enabled"); Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show(); finish(); } } }
From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealSearchFragment.java
/** * Set the text based on google voice then implement search *//*w w w.j av a2 s .c o m*/ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQ_CODE_SPEECH_INPUT) { if (resultCode == Activity.RESULT_OK && null != data) { ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); mEtSearch.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); mEtSearch.setText(result.get(0)); searchFood(mEtSearch.getText().toString(), 0); mItem.clear(); mEtSearchAdapter.notifyDataSetChanged(); mEtSearch.clearFocus(); } } }
From source file:com.ledger.android.u2f.bridge.MainActivity.java
public void postResponse(byte[] responseData) { if (responseData == null) { finish();//from w w w .j a v a 2s .c o m return; } String response = createU2FResponse(mU2FContext, responseData); if (response == null) { finish(); return; } Intent intent = getIntent(); intent.putExtra(TAG_RESULT_DATA, response); setResult(Activity.RESULT_OK, intent); finish(); }
From source file:br.com.GUI.avaliacoes.AvaliarPerimetria.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == 200 || requestCode == 202) { if (requestCode == 200) { selectedImageUri = data.getData(); cortar(requestCode);//from www.ja v a 2s . com } else if (requestCode == 202) { //get the returned data Bundle extras = data.getExtras(); //get the cropped bitmap Bitmap foto = extras.getParcelable("data"); bmp = ImageUtils.compactImages(foto); adicionarFotosPersistencia(bmp); adicionarFotosNaInterface(); } } else if (requestCode == 100 || requestCode == 102) { if (requestCode == 100) { selectedImageUri = data.getData(); cortar(requestCode); } else if (requestCode == 102) { Bundle extras = data.getExtras(); Bitmap foto = extras.getParcelable("data"); bmp = ImageUtils.compactImages(foto); adicionarFotosPersistencia(bmp); adicionarFotosNaInterface(); } } } else { selectedImageUri = null; } /* if(requestCode == 100){ selectedImageUri = Uri.fromFile(photo); ContentResolver cr = getActivity().getContentResolver(); Bitmap foto; try{ foto = android.provider.MediaStore.Images.Media.getBitmap(cr, selectedImageUri); bmp = ImageUtils.compactImages(foto); adicionarFotosPersistencia(bmp); adicionarFotosNaInterface(); }catch(FileNotFoundException e){ Log.i("Exception", e.toString()); e.printStackTrace(); } catch (IOException e){ Log.i("Exception", e.toString()); e.printStackTrace(); } }else if( requestCode == 200){ if (resultCode == Activity.RESULT_OK) { try { Uri selectedImage = data.getData(); String[] nomeCaminho = {MediaStore.Images.Media.DATA}; Cursor cursor = getActivity().getContentResolver().query(selectedImage, nomeCaminho, null, null, null); cursor.moveToFirst(); int indexColuna = cursor.getColumnIndex(nomeCaminho[0]); String caminho = cursor.getString(indexColuna); bmp = ImageUtils.compactImages(BitmapFactory.decodeFile(caminho)); adicionarFotosPersistencia(bmp); adicionarFotosNaInterface(); } catch (Exception e) { Toast.makeText(getActivity(), "Failed to load", Toast.LENGTH_SHORT).show(); Log.e("Camera", e.toString()); } } else { selectedImageUri = null; //bmp.setImageBitmap(null); } } */ }
From source file:com.evolup.test.IAPTest01.util.IabHelper.java
/** * Handles an activity result that's part of the purchase flow in in-app billing. If you * are calling {@link #launchPurchaseFlow}, then you must call this method from your * Activity's {@link android.app.Activity@onActivityResult} method. This method * MUST be called from the UI thread of the Activity. * * @param requestCode The requestCode as you received it. * @param resultCode The resultCode as you received it. * @param data The data (Intent) as you received it. * @return Returns true if the result was related to a purchase flow and was handled; * false if the result was not related to a purchase, in which case you should * handle it normally./*from w w w. j a v a 2s . co m*/ */ public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { IabResult result; if (requestCode != mRequestCode) return false; checkSetupDone("handleActivityResult"); // end of async purchase operation flagEndAsync(); if (data == null) { logError("Null data in IAB activity result."); result = new IabResult(IABHELPER_BAD_RESPONSE, "Null data in IAB result"); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } int responseCode = getResponseCodeFromIntent(data); String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA); String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE); if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) { logDebug("Successful resultcode from purchase activity."); logDebug("Purchase data: " + purchaseData); logDebug("Data signature: " + dataSignature); logDebug("Extras: " + data.getExtras()); if (purchaseData == null || dataSignature == null) { logError("BUG: either purchaseData or dataSignature is null."); logDebug("Extras: " + data.getExtras().toString()); result = new IabResult(IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature"); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } Purchase purchase = null; try { purchase = new Purchase(purchaseData, dataSignature); String sku = purchase.getSku(); // Verify signature if (!Security.verifyPurchase(mSignatureBase64, purchaseData, dataSignature)) { logError("Purchase signature verification FAILED for sku " + sku); result = new IabResult(IABHELPER_VERIFICATION_FAILED, "Signature verification failed for sku " + sku); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, purchase); return true; } logDebug("Purchase signature successfully verified."); } catch (JSONException e) { logError("Failed to parse purchase data."); e.printStackTrace(); result = new IabResult(IABHELPER_BAD_RESPONSE, "Failed to parse purchase data."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } if (mPurchaseListener != null) { mPurchaseListener.onIabPurchaseFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Success"), purchase); } } else if (resultCode == Activity.RESULT_OK) { // result code was OK, but in-app billing response was not OK. logDebug("Result code was OK but in-app billing response was not OK: " + getResponseDesc(responseCode)); if (mPurchaseListener != null) { result = new IabResult(responseCode, "Problem purchashing item."); mPurchaseListener.onIabPurchaseFinished(result, null); } } else if (resultCode == Activity.RESULT_CANCELED) { logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode)); result = new IabResult(IABHELPER_USER_CANCELLED, "User canceled."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); } else { logError("Purchase failed. Result code: " + Integer.toString(resultCode) + ". Response: " + getResponseDesc(responseCode)); result = new IabResult(IABHELPER_UNKNOWN_PURCHASE_RESPONSE, "Unknown purchase response."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); } return true; }
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { if (intent == null || mStatus == null) return;/*from w w w . java2 s .co m*/ switch (requestCode) { case REQUEST_SET_COLOR: { if (resultCode == Activity.RESULT_OK) if (intent != null && intent.getExtras() != null) { final int color = intent.getIntExtra(Accounts.USER_COLOR, Color.TRANSPARENT); setUserColor(getActivity(), mStatus.user_id, color); updateUserColor(); } break; } } }
From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatchFileFragment.java
/** * {@inheritDoc}/* w ww . ja v a 2 s .c o m*/ */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case ACTIVITY_REQUEST_INPUT_FILE: if (data != null && resultCode == Activity.RESULT_OK) { onSelectedInputUri(data.getData()); } break; case ACTIVITY_REQUEST_OUTPUT_FILE: if (data != null && resultCode == Activity.RESULT_OK) { onSelectedOutputUri(data.getData()); } break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:com.mk.a2dp.billingUtil.IabHelper.java
/** * Handles an activity result that's part of the purchase flow in in-app billing. If you * are calling {@link #launchPurchaseFlow}, then you must call this method from your * Activity's {@link android.app.Activity@onActivityResult} method. This method * MUST be called from the UI thread of the Activity. * * @param requestCode The requestCode as you received it. * @param resultCode The resultCode as you received it. * @param data The data (Intent) as you received it. * @return Returns true if the result was related to a purchase flow and was handled; * false if the result was not related to a purchase, in which case you should * handle it normally./*from w w w . ja v a2 s . c o m*/ */ public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { IabResult result; Log.d("iRemote", "0 resultCode = " + resultCode); if (requestCode != mRequestCode) return false; Log.d("iRemote", "1resultCode = " + resultCode); checkSetupDone("handleActivityResult"); // end of async purchase operation flagEndAsync(); Log.d("iRemote", "2"); if (data == null) { Log.d("iRemote", "3"); logError("Null data in IAB activity result."); result = new IabResult(IABHELPER_BAD_RESPONSE, "Null data in IAB result"); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } Log.d("iRemote", "4"); int responseCode = getResponseCodeFromIntent(data); String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA); String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE); Log.d("iRemote", "5 resultCode = " + resultCode); if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) { logDebug("Successful resultcode from purchase activity."); logDebug("Purchase data: " + purchaseData); logDebug("Data signature: " + dataSignature); logDebug("Extras: " + data.getExtras()); if (purchaseData == null || dataSignature == null) { logError("BUG: either purchaseData or dataSignature is null."); logDebug("Extras: " + data.getExtras().toString()); result = new IabResult(IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature"); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } Purchase purchase = null; try { purchase = new Purchase(purchaseData, dataSignature); String sku = purchase.getSku(); // Verify signature if (!Security.verifyPurchase(mSignatureBase64, purchaseData, dataSignature)) { logError("Purchase signature verification FAILED for sku " + sku); result = new IabResult(IABHELPER_VERIFICATION_FAILED, "Signature verification failed for sku " + sku); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, purchase); return true; } logDebug("Purchase signature successfully verified."); } catch (JSONException e) { logError("Failed to parse purchase data."); e.printStackTrace(); result = new IabResult(IABHELPER_BAD_RESPONSE, "Failed to parse purchase data."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } if (mPurchaseListener != null) { mPurchaseListener.onIabPurchaseFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Success"), purchase); } } else if (resultCode == Activity.RESULT_OK) { // result code was OK, but in-app billing response was not OK. logDebug("Result code was OK but in-app billing response was not OK: " + getResponseDesc(responseCode)); if (mPurchaseListener != null) { result = new IabResult(responseCode, "Problem purchashing item."); mPurchaseListener.onIabPurchaseFinished(result, null); } } else if (resultCode == Activity.RESULT_CANCELED) { logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode)); result = new IabResult(IABHELPER_USER_CANCELLED, "User canceled."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); } else { logError("Purchase failed. Result code: " + Integer.toString(resultCode) + ". Response: " + getResponseDesc(responseCode)); result = new IabResult(IABHELPER_UNKNOWN_PURCHASE_RESPONSE, "Unknown purchase response."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); } return true; }