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.insthub.O2OMobile.Activity.F9_SettingActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == REQUEST_CAMERA) {
            File files = new File(mFileName);
            if (files.exists()) {
                mImagePath = mFileName;/*from   www  .j av a 2  s.  c o  m*/
                mImagePath = startPhotoZoom(Uri.fromFile(new File(mImagePath)));
            }
        } else if (requestCode == REQUEST_PHOTO) {
            Uri selectedImage = data.getData();
            mImagePath = startPhotoZoom(selectedImage);
        } else if (requestCode == REQUEST_PHOTOZOOM) {
            File f = new File(mImagePath);
            if (f.exists()) {
                File file = new File(ImageUtil.zoomImage(mImagePath, 350));
                mUserBalance.changeAvatar(file);
            } else {
                ToastView toast = new ToastView(this, getString(R.string.photo_not_exsit));
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
            }
        }
    }
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

public void onOkPressed(View view) {
    setResult(Activity.RESULT_OK);
    finish();
}

From source file:com.facebook.notifications.NotificationsManager.java

/**
 * Handle the result of an activity started using
 * {@code prepare(Context, Bundle, PrepareCallback)} or {@code present(Activity, Bundle)}.
 *
 * @param requestCode The request code used to start the activity
 * @param resultCode  The result code returned by the activity
 * @param data        The data returned by the activity
 * @return The notification card result of the activity if it exists, or null if it does not.
 *//*from   w w  w.  ja  v a  2  s  .  c om*/
public static NotificationCardResult handleActivityResult(int requestCode, int resultCode,
        @Nullable Intent data) {
    if (requestCode != REQUEST_CODE) {
        return null;
    }
    if (resultCode != Activity.RESULT_OK || data == null) {
        return null;
    }

    return data.getParcelableExtra(CardActivity.EXTRA_NOTIFICATION_CARD_RESULT);
}

From source file:$.GooglePlayServicesExtension.java

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        Log.i("yoyo", "gps onActivityResult called with requestCode " + requestCode);

        //   if//w w  w. j  a  va 2  s . c om

        switch (requestCode) {
        case RC_GPS_ACTIVITY:
            if (resultCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
                Log.i("yoyo", "Logging out due to result of GooglePlayServices activity");
                //         Logout();
                if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
                    mGoogleApiClient.disconnect();
                    Log.i("yoyo", "Logged out of Google Play Services");
                    RunnerJNILib.OnLoginSuccess("Not logged in", "-1", "", "", "", "", "");
                }
            }
            break;

        case REQUEST_RESOLVE_ERROR:
            Log.i("yoyo", "onActivityResult called with REQUEST_RESOLVE_ERROR");
            if (resultCode == Activity.RESULT_OK) {
                Log.i("yoyo", "onActivityResult called with REQUEST_RESOLVE_ERROR and resultCode (result_ok)"
                        + resultCode);

                if (mGoogleApiClient != null)
                    if (!mGoogleApiClient.isConnecting() || !mGoogleApiClient.isConnected()) {
                        mResolvingError = false;
                        mGoogleApiClient.connect();

                    }
            } else {
                Log.i("yoyo", "onActivityResult called with REQUEST_RESOLVE_ERROR and resultCode " + resultCode);
                mResolvingError = false;

                switch (resultCode) {
                case GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED");
                    break;
                case GamesActivityResultCodes.RESULT_NETWORK_FAILURE:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_NETWORK_FAILURE");
                    RunnerJNILib.OnLoginSuccess("Not logged in", "-1", "", "", "", "", "");
                    break;
                case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_SIGN_IN_FAILED");
                    RunnerJNILib.OnLoginSuccess("Not logged in", "-1", "", "", "", "", "");
                    break;
                case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_LICENSE_FAILED");
                    RunnerJNILib.OnLoginSuccess("Not logged in", "-1", "", "", "", "", "");
                    break;

                case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_APP_MISCONFIGURED");
                    RunnerJNILib.OnLoginSuccess("Not logged in", "-1", "", "", "", "", "");
                    break;

                case GamesActivityResultCodes.RESULT_INVALID_ROOM:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_INVALID_ROOM");
                    break;
                case GamesActivityResultCodes.RESULT_LEFT_ROOM:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_LEFT_ROOM");
                    break;
                case GamesActivityResultCodes.RESULT_SEND_REQUEST_FAILED:
                    Log.i("yoyo", "gps OnActivityResult with: GamesActivityResultCodes.RESULT_SEND_REQUEST_FAILED");
                    break;

                }

                SendSocialEvent("GPSGamesActivityResult", (double) resultCode);

                //going to stop putting up the gps error as it's not at all helpful
                //showErrorDialog(resultCode,requestCode);
                //We have an error and haven't been able to resolve it...
            }
            break;
        default:

            Log.i("yoyo", "onActivityResult called with " + requestCode);

            mResolvingError = false;
            break;
        }
    }

From source file:com.firesoft.member.Activity.F9_SettingActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == REQUEST_CAMERA) {
            File files = new File(mFileName);
            if (files.exists()) {
                mImagePath = mFileName;//from w  ww . j a  va  2 s.c o  m
                mImagePath = startPhotoZoom(Uri.fromFile(new File(mImagePath)));
            }
        } else if (requestCode == REQUEST_PHOTO) {
            Uri selectedImage = data.getData();
            mImagePath = startPhotoZoom(selectedImage);
        }
    }
}

From source file:com.polyvi.xface.extension.camera.XCameraExt.java

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (CAMERA_REQUEST_CODE == requestCode) {
        if (resultCode != Activity.RESULT_OK) {
            XLog.i(CLASS_NAME, "Camera cancelled.");
            mCallbackCtx.error("Camera cancelled.");
            return;
        }/*from w  ww  . j a v a  2 s  . co  m*/
        if (!mAllowEdit) {
            cameraSucess(intent);
        } else {
            startCutPhotoAfterCamera(intent);
        }
    } else if (PHOTO_REQUEST_CODE == requestCode) {
        if (resultCode != Activity.RESULT_OK || null == intent) {
            XLog.e(CLASS_NAME, "Selection cancelled.");
            mCallbackCtx.error("Selection cancelled.");
            return;
        }
        if (!mAllowEdit) {
            photoSucess(intent);
        } else {
            mImageUri = intent.getData();
            startCutPhoto(mImageUri);
        }
    } else {
        if (resultCode != Activity.RESULT_OK || null == intent) {
            XLog.e(CLASS_NAME, "cut picture cancelled.");
            mCallbackCtx.error("cut picture cancelled.");
            return;
        }
        if (mSrcType == CAMERA) {
            cameraSucess(intent);
        } else if ((mSrcType == PHOTOLIBRARY) || (mSrcType == SAVEDPHOTOALBUM)) {
            photoSucess(intent);
        }
    }
}

From source file:cc.mintcoin.wallet.ui.RequestCoinsFragment.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (requestCode == REQUEST_CODE_ENABLE_BLUETOOTH) {
        acceptBluetoothPaymentView.setChecked(resultCode == Activity.RESULT_OK);

        if (resultCode == Activity.RESULT_OK && bluetoothAdapter != null)
            startBluetoothListening();//from  w w  w .j av a 2s . c  om

        if (isResumed())
            updateView();
    }
}

From source file:bluetooth.BluetoothChatFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CONNECT_DEVICE_SECURE:
        // When DeviceListActivity returns with a device to connect
        if (resultCode == Activity.RESULT_OK) {
            connectDevice(data, true);//from  ww w.  j a v  a  2 s.  c om
        }
        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(getActivity(), R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
            getActivity().finish();
        }
    }
}

From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java

/**
 * Closes the dialog / activity/*from   w w  w  .ja v a2s  .c o m*/
 */
void close() {
    Intent data = new Intent();
    data.putExtra(Constants.RESULT_LYDIA_VALUE, 2);
    if (getParent() == null) {
        setResult(Activity.RESULT_OK, data);
    } else {
        getParent().setResult(Activity.RESULT_OK, data);
    }
    LydiaActivity.this.finish();
}

From source file:cz.zcu.kiv.eeg.mobile.base.ui.scenario.ScenarioAddActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    //obtaining file selected in FileChooserActivity
    case (Values.SELECT_FILE_FLAG): {
        if (resultCode == Activity.RESULT_OK) {
            selectedFile = data.getExtras().getString(Values.FILE_PATH);
            selectedFileLength = data.getExtras().getLong(Values.FILE_LENGTH);
            TextView selectedFileView = (TextView) findViewById(R.id.fchooserSelectedFile);
            EditText mimeView = (EditText) findViewById(R.id.scenario_mime_value);
            TextView fileSizeView = (TextView) findViewById(R.id.scenario_file_size_value);

            FileSystemResource file = new FileSystemResource(selectedFile);
            selectedFileView.setText(file.getFilename());
            mimeView.setText(FileUtils.getMimeType(selectedFile));

            String fileSize = FileUtils.getFileSize(file.getFile().length());
            fileSizeView.setText(fileSize);
            Toast.makeText(this, selectedFile, Toast.LENGTH_SHORT).show();
        }//  w  w  w . j  a v  a2  s .  c  om
        break;
    }
    }
}