Example usage for android.app Activity RESULT_OK

List of usage examples for android.app Activity RESULT_OK

Introduction

In this page you can find the example usage for android.app Activity RESULT_OK.

Prototype

int RESULT_OK

To view the source code for android.app Activity RESULT_OK.

Click Source Link

Document

Standard activity result: operation succeeded.

Usage

From source file:com.shome.rubyshop.LoginActivity.java

void Finish() {
    Intent resultIntent = new Intent();
    setResult(Activity.RESULT_OK, resultIntent);
    //dialog.cancel();
    finish();
}

From source file:com.vladstirbu.cordova.CDVInstagramVideoPlugin.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        Log.v("InstagramVideo", "shared ok");
        this.cbContext.success();
    } else if (resultCode == Activity.RESULT_CANCELED) {
        Log.v("InstagramVideo", "share cancelled");
        this.cbContext.error("Share Cancelled");
    }//from   w w  w.ja  va  2 s  .c  o m
}

From source file:com.adobe.phonegap.csdk.ImageEditor.java

/**
 * Called when the image editor exits./* www  .j  av  a2s .c o m*/
 *
 * @param requestCode       The request code originally supplied to startActivityForResult(),
 *                          allowing you to identify who this result came from.
 * @param resultCode        The integer result code returned by the child activity through its setResult().
 * @param intent            An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
 */
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
        case 1:
            Uri editedImageUri = intent.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI);
            this.callbackContext.success(editedImageUri.toString());

            break;
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        this.callbackContext.error("Editor Canceled");
    }
}

From source file:com.clearbon.cordova.netswipe.NetSwipePlugin.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == NetswipeSDK.REQUEST_CODE) {
        /*ArrayList<String> scanAttempts = 
        data.getStringArrayListExtra(NetswipeSDK.EXTRA_SCAN_ATTEMPTS);*/
        if (resultCode == Activity.RESULT_OK) {
            NetswipeCardInformation cardInformation = data
                    .getParcelableExtra(NetswipeSDK.EXTRA_CARD_INFORMATION);

            //TODO card type
            //CreditCardType creditCardType = cardInformation.getCardType();

            JSONObject cardInfo = new JSONObject();
            try {
                cardInfo.put("cardNumber", getStringValue(cardInformation.getCardNumber(), true));
                cardInfo.put("expiryMonth", getStringValue(cardInformation.getExpiryDateMonth(), false));
                cardInfo.put("expiryYear", getStringValue(cardInformation.getExpiryDateYear(), false));
                cardInfo.put("cvv", getStringValue(cardInformation.getCvvCode(), false));
                cardInfo.put("cardHolderName", getStringValue(cardInformation.getCardHolderName(), false));
                cardInfo.put("sortCode", getStringValue(cardInformation.getSortCode(), false));
                cardInfo.put("accountNumber", getStringValue(cardInformation.getAccountNumber(), false));
                cardInfo.put("cardNumberManuallyEntered", cardInformation.isCardNumberManuallyEntered());

                //TODO custom fields
                //String zipCode = cardInformation.getCustomField("zip_code");

                callbackContext.success(cardInfo);

            } catch (JSONException e) {
                Log.e(LogTag, "Error creating return parameters for success callback.", e);
            } finally {
                cardInformation.clear();
                cardInfo.remove("cardNumber");
                cardInfo.remove("expiryMonth");
                cardInfo.remove("expiryYear");
                cardInfo.remove("cvv");
                cardInfo.remove("cardHolderName");
                cardInfo.remove("sortCode");
                cardInfo.remove("accountNumber");
                cardInfo.remove("cardNumberManuallyEntered");
                cardInfo = null;//from   w ww  .j  a v  a2s  .  com
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            try {
                int errorCode = data.getIntExtra(NetswipeSDK.EXTRA_ERROR_CODE, 0);
                String errorMessage = data.getStringExtra(NetswipeSDK.EXTRA_ERROR_MESSAGE);

                JSONObject cardInfo = new JSONObject();
                cardInfo.put("code", errorCode);
                cardInfo.put("message", errorMessage);

                callbackContext.error(cardInfo);
            } catch (JSONException e) {
                Log.e(LogTag, "Error creating return parameters for error callback.", e);
            }
        }
    }
}

From source file:ca.six.unittestapp.todo.taskdetail.TaskDetailFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_EDIT_TASK) {
        // If the task was edited successfully, go back to the list.
        if (resultCode == Activity.RESULT_OK) {
            getActivity().finish();//from  w  w w.j  a v a 2s . co m
        }
    }
}

From source file:net.internetTelephone.program.project.init.create.ProjectCreateFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RESULT_REQUEST_PHOTO) {
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                fileUri = data.getData();
            }//from w  w w  .ja  va2 s. c om
            fileCropUri = CameraPhotoUtil.getOutputMediaFileUri();
            Global.cropImageUri(this, fileUri, fileCropUri, 600, 600, RESULT_REQUEST_PHOTO_CROP);
        }

    } else if (requestCode == RESULT_REQUEST_PHOTO_CROP) {
        if (resultCode == Activity.RESULT_OK) {
            try {
                String filePath = FileUtil.getPath(getActivity(), fileCropUri);
                projectIcon.setImageURI(fileCropUri);
                projectInfo.icon = filePath;

            } catch (Exception e) {
                Global.errorLog(e);
            }
        }
    } else if (requestCode == RESULT_REQUEST_PICK_TYPE) {
        if (resultCode == Activity.RESULT_OK) {
            String type = data.getStringExtra("type");
            if (TextUtils.isEmpty(type)) {
                return;
            }
            currentType = type;
            projectTypeText.setText(currentType);
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:com.google.cloud.solutions.smashpix.MainActivity.java

  @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  if (resultCode == Activity.RESULT_OK) {
    if (requestCode == Constants.TAKE_PICTURE) {
      new UploadImageTask(this).execute();
    } else if (requestCode == Constants.SELECT_PICTURE) {
      if (data.getData().getPath().startsWith(PICASA_URI_PREFIX))  {
        new DownloadGooglePhotoTask(this).execute(data.getData());
      } else  {//from   w w w  . j  av a  2 s . c o  m
        imageStoragePath = new File(getPathFromData(data.getData()));
        new UploadImageTask(this).execute();
      }
    }
  }
}

From source file:com.owncloud.activity.Downloader.java

public void downloadFile(Intent i) {
    if (isOnline()) {
        String url = i.getData().toString();
        GetMethod gm = new GetMethod(url);

        try {//from   w w w. j a v  a  2s. co  m
            int status = BaseActivity.httpClient.executeMethod(gm);
            //            Toast.makeText(getApplicationContext(), String.valueOf(status),2).show();
            Log.e("HttpStatus", "==============>" + String.valueOf(status));
            if (status == HttpStatus.SC_OK) {
                InputStream input = gm.getResponseBodyAsStream();

                String fileName = new StringBuffer(url).reverse().toString();
                String[] fileNameArray = fileName.split("/");
                fileName = new StringBuffer(fileNameArray[0]).reverse().toString();

                fileName = URLDecoder.decode(fileName);
                File folder = new File(BaseActivity.mDownloadDest);
                boolean success = false;
                if (!folder.exists()) {
                    success = folder.mkdir();
                }
                if (!success) {
                    // Do something on success
                    File file = new File(BaseActivity.mDownloadDest, fileName);
                    OutputStream fOut = new FileOutputStream(file);

                    int byteCount = 0;
                    byte[] buffer = new byte[4096];
                    int bytesRead = -1;

                    while ((bytesRead = input.read(buffer)) != -1) {
                        fOut.write(buffer, 0, bytesRead);
                        byteCount += bytesRead;
                        //                     DashBoardActivity.updateNotation();
                    }

                    fOut.flush();
                    fOut.close();
                } else {
                    // Do something else on failure
                    Log.d("Download Prob..", String.valueOf(success) + ", Some problem in folder creating");
                }

            }
        } catch (HttpException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        gm.releaseConnection();

        Bundle extras = i.getExtras();

        if (extras != null) {
            Messenger messenger = (Messenger) extras.get(EXTRA_MESSENGER);
            Message msg = Message.obtain();

            msg.arg1 = Activity.RESULT_OK;

            try {
                messenger.send(msg);
            } catch (android.os.RemoteException e1) {
                Log.w(getClass().getName(), "Exception sending message", e1);
            }
        }
    } else {
        WebNetworkAlert();
    }
}

From source file:net.coding.program.project.init.create.ProjectCreateFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RESULT_REQUEST_PHOTO) {
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                fileUri = data.getData();
            }/* w w w .  jav a 2 s . co m*/
            fileCropUri = CameraPhotoUtil.getOutputMediaFileUri();
            Global.cropImageUri(this, fileUri, fileCropUri, 600, 600, RESULT_REQUEST_PHOTO_CROP);
        }

    } else if (requestCode == RESULT_REQUEST_PHOTO_CROP) {
        if (resultCode == Activity.RESULT_OK) {
            try {
                String filePath = Global.getPath(getActivity(), fileCropUri);
                projectIcon.setImageURI(fileCropUri);
                projectInfo.icon = filePath;

            } catch (Exception e) {
                Global.errorLog(e);
            }
        }
    } else if (requestCode == RESULT_REQUEST_PICK_TYPE) {
        if (resultCode == Activity.RESULT_OK) {
            String type = data.getStringExtra("type");
            if (TextUtils.isEmpty(type)) {
                return;
            }
            currentType = type;
            projectTypeText.setText(currentType);
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:com.example.office.ui.mail.MailItemFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case MailItemActivity.CAMERA_REQUEST_CODE:
        if (resultCode == Activity.RESULT_OK) {
            try {
                String currentPhotoPath = ((MailItemActivity) getActivity()).getCurrentPhotoPath();
                Bitmap bmp = BitmapFactory.decodeFile(currentPhotoPath);
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                bmp.compress(CompressFormat.JPEG, 100, stream);

                MailItem mail = (MailItem) getActivity().getIntent().getExtras()
                        .get(getString(R.string.intent_mail_key));
                Utility.showToastNotification("Starting file uploading");
                mId = mail.getId();/*from w w w  . j a  v a2s. c o  m*/
                mImageBytes = stream.toByteArray();
                mFilename = StringUtils.substringAfterLast(currentPhotoPath, "/");
                getMessageAndAttachData();
            } catch (Exception e) {
                Utility.showToastNotification("Error during getting image from camera");
            }

        }
        break;

    case MailItemActivity.SELECT_PHOTO:
        if (resultCode == Activity.RESULT_OK) {
            try {
                Uri selectedImage = data.getData();
                InputStream imageStream = getActivity().getContentResolver().openInputStream(selectedImage);
                MailItem mail = (MailItem) getActivity().getIntent().getExtras()
                        .get(getString(R.string.intent_mail_key));
                Utility.showToastNotification("Starting file uploading");
                mId = mail.getId();
                mImageBytes = IOUtils.toByteArray(imageStream);
                mFilename = selectedImage.getLastPathSegment();
                getMessageAndAttachData();
            } catch (Throwable t) {
                Utility.showToastNotification("Error during getting image from file");
            }
        }
        break;

    default:
        super.onActivityResult(requestCode, resultCode, data);
    }

}