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:com.example.cuisoap.agrimac.machineRegister.driverInfoFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri license_uri = data.getData(); Log.e("uri", license_uri.toString()); ContentResolver cr = context.getContentResolver(); try {//from w w w.j a v a 2s. c o m Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(license_uri)); if (requestCode == 1) { //String path=getRealPathFromURI(uri); //System.out.println(path); bitmap = ImageUtils.comp(bitmap); license_path = ImageUtils.saveMyBitmap(bitmap, "driver"); license_pic.setImageBitmap(bitmap); license_pic.setVisibility(View.VISIBLE); license.setVisibility(View.GONE); license_pic.setOnClickListener(myOnClickListener); } } 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.sourceallies.android.zonebeacon.activity.TransferActivityTest.java
@Test public void test_onActivityResult_successful_dontShareData() { activity.setResolvingError(true);/*w ww . j ava2s. c om*/ activity.setShareData(false); activity.onActivityResult(1, Activity.RESULT_OK, null); assertFalse(activity.isResolvingError()); }
From source file:br.com.GUI.perfil.PerfilPersonal.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 w w w.j a v a2 s .c om*/ /*selectedImageUri = Uri.fromFile(photo); ContentResolver cr = getContentResolver(); Bitmap foto; try{ foto = android.provider.MediaStore.Images.Media.getBitmap(cr, selectedImageUri); bmp = ImageUtils.compactImages(foto); imagem.setImageBitmap(foto); }catch(FileNotFoundException e){ Log.i("Exception", e.toString()); e.printStackTrace(); } catch (IOException e){ }*/ } 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); img.setImageBitmap(bmp); Log.i("tirei a foto ", "e setei no canvas"); Personal p = new Personal(); p.setUsuario(pref.getString("usuario", null)); if (p.editarFotoPersonalWeb(ImageUtils.bitmapToByteArray(bmp))) { Log.i("salvei web", "salvei web"); if (p.editarFotoPersonal(b, ImageUtils.bitmapToByteArray(bmp))) { Log.i("salvei local", "salvei local"); refresh(); Toast.makeText(getActivity(), "Atualizada com sucesso!", Toast.LENGTH_SHORT).show(); } } Log.i("setei", "no primeirro"); } } else if (requestCode == 100 || requestCode == 102) { if (requestCode == 100) { selectedImageUri = data.getData(); cortar(requestCode); } else if (requestCode == 102) { //get the returned data Bundle extras = data.getExtras(); //get the cropped bitmap Bitmap foto = extras.getParcelable("data"); bmp = ImageUtils.compactImages(foto); Log.i("tirei a foto ", "e setei no canvas"); Personal p = new Personal(); p.setUsuario(pref.getString("usuario", null)); if (p.editarFotoPersonalWeb(ImageUtils.bitmapToByteArray(bmp))) { Log.i("salvei web", "salvei web"); if (p.editarFotoPersonal(b, ImageUtils.bitmapToByteArray(bmp))) { Log.i("salvei local", "salvei local"); img.setImageBitmap(bmp); Toast.makeText(getActivity(), "Atualizada com sucesso!", Toast.LENGTH_SHORT).show(); } } Log.i("setei", "no primeirro"); refresh(); } /*try { Uri selectedImage = data.getData(); String[] nomeCaminho = {MediaStore.Images.Media.DATA}; Cursor cursor = 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)); imagem.setImageBitmap(BitmapFactory.decodeFile(caminho)); } catch (Exception e) { Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT).show(); Log.e("Camera", e.toString()); } */ } } else { selectedImageUri = null; img.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.profile)); } }
From source file:com.example.android.location.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { // Choose what to do based on the request code switch (requestCode) { // If the request code matches the code sent in onConnectionFailed case LocationUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST: switch (resultCode) { // If Google Play services resolved the problem case Activity.RESULT_OK: // Log the result Log.d(LocationUtils.APPTAG, getString(R.string.resolved)); // Display the result mConnectionState.setText(R.string.connected); mConnectionStatus.setText(R.string.resolved); break; // If any other result was returned by Google Play services default://from ww w . j a v a 2 s. c o m // Log the result Log.d(LocationUtils.APPTAG, getString(R.string.no_resolution)); // Display the result mConnectionState.setText(R.string.disconnected); mConnectionStatus.setText(R.string.no_resolution); break; } // If any other request code was received default: // Report that this Activity received an unknown requestCode Log.d(LocationUtils.APPTAG, getString(R.string.unknown_activity_request_code, requestCode)); break; } }
From source file:org.runnerup.export.RunKeeperSynchronizer.java
@Override public Status getAuthResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { String authConfig = data.getStringExtra(DB.ACCOUNT.AUTH_CONFIG); try {//from www . j a v a 2 s . c om access_token = new JSONObject(authConfig).getString("access_token"); return Status.OK; } catch (JSONException e) { Log.e(Constants.LOG, e.getMessage()); } } return Status.ERROR; }
From source file:br.org.funcate.dynamicforms.FormActivity.java
private void saveAction() throws Exception { // if in landscape mode store last inserted info, since that fragment has not been stored FragmentDetail detailFragment = (FragmentDetail) getSupportFragmentManager() .findFragmentById(R.id.detailFragment); if (detailFragment != null) { detailFragment.storeFormItems(false); }//from ww w.ja v a2 s .c o m // extract and check constraints List<String> availableFormNames = TagsManager.getFormNames4Section(sectionObject); String renderingLabel = null; for (String formName : availableFormNames) { JSONObject formObject = TagsManager.getForm4Name(formName, sectionObject); JSONArray formItemsArray = TagsManager.getFormItems(formObject); if (formItemsArray == null) continue; int length = formItemsArray.length(); String value = null; for (int i = 0; i < length; i++) { JSONObject jsonObject = formItemsArray.getJSONObject(i); String key = "-"; if (jsonObject.has(TAG_KEY)) key = jsonObject.getString(TAG_KEY).trim(); if (jsonObject.has(TAG_VALUE)) { value = jsonObject.getString(TAG_VALUE).trim(); } if (jsonObject.has(TAG_IS_RENDER_LABEL)) { String isRenderingLabelStr = jsonObject.getString(TAG_IS_RENDER_LABEL).trim(); boolean isRenderingLabel = Boolean.parseBoolean(isRenderingLabelStr); if (isRenderingLabel) renderingLabel = value; } // inject latitude if (key.equals(LibraryConstants.LATITUDE)) { String latitudeString = String.valueOf(latitude); value = latitudeString; jsonObject.put(TAG_VALUE, latitudeString); } // inject longitude if (key.equals(LibraryConstants.LONGITUDE)) { String longitudeString = String.valueOf(longitude); value = longitudeString; jsonObject.put(TAG_VALUE, longitudeString); } Constraints constraints = FormUtilities.handleConstraints(jsonObject, null); if (value == null || !constraints.isValid(value)) { String constraintDescription = constraints.getDescription(); String validfieldMsg = getString(R.string.form_field_check); String msg = Utilities.format(validfieldMsg, key, formName, constraintDescription); Utilities.messageDialog(this, msg, null); return; } } } // finally store data String sectionObjectString = sectionObject.toString(); long timestamp = System.currentTimeMillis(); if (renderingLabel == null) { renderingLabel = sectionName; } String[] formDataArray = { // String.valueOf(noteId), // String.valueOf(longitude), // String.valueOf(latitude), // String.valueOf(elevation), // String.valueOf(timestamp), // renderingLabel, // "POI", // sectionObjectString }; Intent intent = getIntent(); intent.putExtra(LibraryConstants.PREFS_KEY_FORM, formDataArray); setResult(Activity.RESULT_OK, intent); finish(); }
From source file:com.orange.ocara.ui.activity.EditAuditActivity.java
@OnActivityResult(CREATE_SITE_REQUEST_CODE) void onResult(int resultCode, @org.androidannotations.annotations.OnActivityResult.Extra(value = "siteId") Long siteId) { if (resultCode == Activity.RESULT_OK) { Timber.v("Site ok"); currentSite = modelManager.getSite(siteId); setSite(currentSite);/*from w w w. jav a 2 s .c o m*/ site.requestFocus(); } }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_BT_BROADCAST) { if (resultCode > 0) { Toast.makeText(getActivity(), "Bluetooth sharing enabled.", 500).show(); broadcastBluetooth();/*from w w w . j a v a2 s.c om*/ } else { return; } } if (requestCode == REQUEST_BT_ENABLE) { if (resultCode != Activity.RESULT_OK) { return; } else { requestBluetooth(); } } }
From source file:app.com.vaipo.ContactsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == Activity.RESULT_OK) { int action = data.getIntExtra("action", InCallActivityDialog.ACTION_NONE); int option = data.getIntExtra("option", InCallActivityDialog.OPTION_NONE); switch (action) { case InCallActivityDialog.ACTION_END: Utils.endVaipoCall(getActivity()); break; case InCallActivityDialog.ACTION_MUTE: break; case InCallActivityDialog.ACTION_SPKR: break; case InCallActivityDialog.ACTION_SWAP: break; }//w w w . jav a2s . com } if (resultCode == Activity.RESULT_CANCELED) { //Write your code if there's no result } } }
From source file:com.soomla.store.billing.google.GoogleIabHelper.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 av a 2s. co m*/ */ public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { IabResult result; if (requestCode != RC_REQUEST) return false; checkSetupDoneAndThrow("handleActivityResult"); // cancellation moved here b/c there can be a cancellation with null data if (resultCode == Activity.RESULT_CANCELED) { SoomlaUtils.LogDebug(TAG, "IabPurchase canceled."); try { IabPurchase purchase = new IabPurchase(mPurchasingItemType, "{\"productId\":" + mPurchasingItemSku + "}", null); result = new IabResult(IabResult.BILLING_RESPONSE_RESULT_USER_CANCELED, "User canceled."); purchaseFailed(result, purchase); return true; } catch (JSONException e) { SoomlaUtils.LogError(TAG, "Failed to generate canceled purchase."); e.printStackTrace(); result = new IabResult(IabResult.IABHELPER_BAD_RESPONSE, "Failed to generate canceled purchase."); purchaseFailed(result, null); return true; } } if (data == null) { SoomlaUtils.LogError(TAG, "Null data in IAB activity result."); result = new IabResult(IabResult.IABHELPER_BAD_RESPONSE, "Null data in IAB result"); purchaseFailed(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 == IabResult.BILLING_RESPONSE_RESULT_OK) { SoomlaUtils.LogDebug(TAG, "Successful resultcode from purchase activity."); SoomlaUtils.LogDebug(TAG, "IabPurchase data: " + purchaseData); SoomlaUtils.LogDebug(TAG, "Data signature: " + dataSignature); SoomlaUtils.LogDebug(TAG, "Extras: " + data.getExtras()); SoomlaUtils.LogDebug(TAG, "Expected item type: " + mPurchasingItemType); if (purchaseData == null || dataSignature == null) { SoomlaUtils.LogError(TAG, "BUG: either purchaseData or dataSignature is null."); SoomlaUtils.LogDebug(TAG, "Extras: " + data.getExtras().toString()); result = new IabResult(IabResult.IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature"); purchaseFailed(result, null); return true; } IabPurchase purchase = null; try { purchase = new IabPurchase(mPurchasingItemType, purchaseData, dataSignature); String sku = purchase.getSku(); SharedPreferences prefs = SoomlaApp.getAppContext().getSharedPreferences(SoomlaConfig.PREFS_NAME, Context.MODE_PRIVATE); String publicKey = prefs.getString(GooglePlayIabService.PUBLICKEY_KEY, ""); // Verify signature if (!Security.verifyPurchase(publicKey, purchaseData, dataSignature)) { SoomlaUtils.LogError(TAG, "IabPurchase signature verification FAILED for sku " + sku); result = new IabResult(IabResult.IABHELPER_VERIFICATION_FAILED, "Signature verification failed for sku " + sku); purchaseFailed(result, purchase); return true; } SoomlaUtils.LogDebug(TAG, "IabPurchase signature successfully verified."); } catch (JSONException e) { SoomlaUtils.LogError(TAG, "Failed to parse purchase data."); e.printStackTrace(); result = new IabResult(IabResult.IABHELPER_BAD_RESPONSE, "Failed to parse purchase data."); purchaseFailed(result, null); return true; } purchaseSucceeded(purchase); } else if (resultCode == Activity.RESULT_OK) { // result code was OK, but in-app billing response was not OK. SoomlaUtils.LogDebug(TAG, "Result code was OK but in-app billing response was not OK: " + IabResult.getResponseDesc(responseCode)); result = new IabResult(responseCode, "Problem purchashing item."); purchaseFailed(result, null); } else { SoomlaUtils.LogError(TAG, "IabPurchase failed. Result code: " + Integer.toString(resultCode) + ". Response: " + IabResult.getResponseDesc(responseCode)); result = new IabResult(IabResult.IABHELPER_UNKNOWN_PURCHASE_RESPONSE, "Unknown purchase response."); purchaseFailed(result, null); } return true; }