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.sourceallies.android.zonebeacon.activity.TransferActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUEST_RESOLVE_ERROR) {
        // User was presented with the Nearby opt-in dialog and pressed "Allow".
        resolvingError = false;//www .  j a  va 2s.co  m

        if (resultCode == Activity.RESULT_OK) {
            if (shareData) {
                publish(client, message);
            } else {
                subscribe(client, messageListener);
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            finish();
        } else {
            Toast.makeText(this, "Failed to resolve error with code " + resultCode, Toast.LENGTH_LONG).show();
        }
    }
}

From source file:fr.cph.stock.android.activity.AccountActivity.java

@Override
public void reloadData(Portfolio portfolio) {
    menuItem.collapseActionView();/*  w  w w.  j ava  2 s  .c  o  m*/
    menuItem.setActionView(null);
    this.portfolio = portfolio;
    Intent resultIntent = new Intent();
    resultIntent.putExtra("portfolio", portfolio);
    setResult(Activity.RESULT_OK, resultIntent);
    buildUi(true);
    StockTrackerApp app = (StockTrackerApp) getApplication();
    app.toast();
}

From source file:com.apptentive.android.sdk.ViewActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
        case Constants.REQUEST_CODE_PHOTO_FROM_MESSAGE_CENTER:
            MessageCenterView.showAttachmentDialog(this, data.getData());
            break;
        default:/*from w w w  .  jav  a  2 s. c o  m*/
            break;
        }
    }
}

From source file:com.wodify.cordova.plugin.filepicker.FilePicker.java

/**
 * Called when the file picker view exits.
 *
 * @param requestCode/*from  w w  w  . jav  a  2  s.c  o  m*/
 *        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 && intent != null) {
        final Intent i = intent;
        cordova.getThreadPool().execute(new Runnable() {
            public void run() {
                processResult(i);
            }
        });
    } else if (resultCode == Activity.RESULT_CANCELED) {
        this.failFile("Selection cancelled.");
    } else {
        this.failFile("Selection did not complete!");
    }
}

From source file:com.abhijitvalluri.android.fitnotifications.HomeActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case APP_INTRO_FIRST_LAUNCH_INTENT:
        if (resultCode == Activity.RESULT_OK) {
            mPreferences.edit().putBoolean(getString(R.string.done_first_launch_key), true).apply();
        } else {//from  ww  w. j  av a 2 s  .c om
            new AlertDialog.Builder(HomeActivity.this).setMessage(getString(R.string.setup_incomplete))
                    .setTitle(getString(R.string.setup_incomplete_title))
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            startActivityForResult(new Intent(HomeActivity.this, AppIntroActivity.class),
                                    APP_INTRO_FIRST_LAUNCH_INTENT, LAUNCH_ACTIVITY_ANIM_BUNDLE);
                        }
                    }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mPreferences.edit().putBoolean(getString(R.string.done_first_launch_key), true)
                                    .apply();
                            Toast.makeText(HomeActivity.this,
                                    "Okay, you can check out the new setup process at any time!",
                                    Toast.LENGTH_LONG).show();
                        }
                    }).create().show();
        }
        return;
    default:
    }
}

From source file:com.c4fcm.actionpath.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 GeofenceUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST:

        switch (resultCode) {
        // If Google Play services resolved the problem
        case Activity.RESULT_OK:

            // If the request was to add geofences
            if (GeofenceUtils.REQUEST_TYPE.ADD == mRequestType) {

                // Toggle the request flag and send a new request
                mGeofenceRequester.setInProgressFlag(false);

                // Restart the process of adding the current geofences
                mGeofenceRequester.addGeofences(mCurrentGeofences);

                // If the request was to remove geofences
            } else if (GeofenceUtils.REQUEST_TYPE.REMOVE == mRequestType) {

                // Toggle the removal flag and send a new removal request
                mGeofenceRemover.setInProgressFlag(false);

                // If the removal was by Intent
                if (GeofenceUtils.REMOVE_TYPE.INTENT == mRemoveType) {

                    // Restart the removal of all geofences for the PendingIntent
                    mGeofenceRemover.removeGeofencesByIntent(mGeofenceRequester.getRequestPendingIntent());

                    // If the removal was by a List of geofence IDs
                } else {

                    // Restart the removal of the geofence list
                    mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove);
                }//w  w w  .  ja va  2  s .co m
            }
            break;

        // If any other result was returned by Google Play services
        default:

            // Report that Google Play services was unable to resolve the problem.
            Log.d(GeofenceUtils.APPTAG, getString(R.string.no_resolution));
        }

        // If any other request code was received
    default:
        // Report that this Activity received an unknown requestCode
        Log.d(GeofenceUtils.APPTAG, getString(R.string.unknown_activity_request_code, requestCode));

        break;
    }
}

From source file:cw.kop.autobackground.settings.AppSettingsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
    case TutorialActivity.TUTORIAL_REQUEST:
        restartActivity();// w w w . j ava2  s. com
        break;
    case IMPORT_SOURCES_REQUEST_CODE:
        if (resultCode == Activity.RESULT_OK) {
            File file = new File(data.getData().getPath());
            importSources(file);
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.jaspersoft.android.jaspermobile.activities.profile.fragment.ServersFragment.java

private void setResultOk(long profileId) {
    Intent resultIntent = new Intent();
    resultIntent.putExtra(EXTRA_SERVER_PROFILE_ID, profileId);
    getActivity().setResult(Activity.RESULT_OK, resultIntent);
    getActivity().finish();// www.  j a  v a  2s . c  o m
}

From source file:ca.rmen.android.scrumchatter.main.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == ACTIVITY_REQUEST_CODE_IMPORT && resultCode == Activity.RESULT_OK) {
        if (intent.getData() == null) {
            Toast.makeText(this, R.string.import_result_no_file, Toast.LENGTH_SHORT).show();
            return;
        }/*from   w w w .j av  a 2  s.  co m*/
        final String filePath = intent.getData().getPath();
        if (TextUtils.isEmpty(filePath)) {
            Toast.makeText(this, R.string.import_result_no_file, Toast.LENGTH_SHORT).show();
            return;
        }
        final File file = new File(filePath);
        if (!file.exists()) {
            Toast.makeText(this, getString(R.string.import_result_file_does_not_exist, file.getName()),
                    Toast.LENGTH_SHORT).show();
            return;
        }
        importDB(Uri.fromFile(file));
    } else {
        super.onActivityResult(requestCode, resultCode, intent);
    }
}