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.etalio.android.EtalioBase.java

/**
 * Call this method in authenticating activity's onActivityResult to handle Etalio single sign on results.
 * @param requestCode/*  w w w.  j ava2  s .  co m*/
 * @param resultCode
 * @param data
 */
public void onActivityResult(int requestCode, int resultCode, Intent data, AuthenticationCallback callback) {
    if (requestCode == REQUEST_CODE_SSO && resultCode == Activity.RESULT_OK) {
        String accessToken = data.getStringExtra(EtalioBase.EXTRA_ACCESS_TOKEN);
        String refreshToken = data.getStringExtra(EtalioBase.EXTRA_REFRESH_TOKEN);
        int expiresIn = data.getIntExtra(EtalioBase.EXTRA_EXPIRES_IN, 0);
        setEtalioToken(new EtalioToken(accessToken, refreshToken, expiresIn));
        callback.onAuthenticationSuccess();
    } else {
        callback.onAuthenticationFailure(
                new EtalioTokenException(EtalioTokenException.TokensErrorResponse.INVALID_RESPONSE));
    }
}

From source file:org.safegees.safegees.gui.view.MainActivity.java

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

    if (requestCode == 1) {
        if (resultCode == Activity.RESULT_OK) {
            shareDataWithServer();/*from   ww  w  . j  a va 2 s .  c o m*/
        }
        if (resultCode == Activity.RESULT_CANCELED) {
            //Write your code if there's no result
            start();
        }
    }
}

From source file:com.facebook.android.friendsmash.HomeFragment.java

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

    if (requestCode == REAUTH_ACTIVITY_CODE) {
        // This ensures a session state change is recorded so that the tokenUpdated() callback is triggered
        // to attempt a post if the write permissions have been granted
        Log.i(FriendSmashApplication.TAG, "Reauthorized with publish permissions.");
        Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data);
    } else if (resultCode == Activity.RESULT_OK && data != null) {
        // Finished a game
        Bundle bundle = data.getExtras();
        application.setScore(bundle.getInt("score"));
        updateYouScoredTextView();/*  w  w w.jav  a  2s  .com*/
        updateButtonVisibility();
        completeGameOver(1500);
    } else if (resultCode == Activity.RESULT_FIRST_USER && data != null) {
        // Came from the ScoreboardFragment, so start a game with the specific user who has been clicked
        Intent i = new Intent(getActivity(), GameActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("user_id", data.getStringExtra("user_id"));
        i.putExtras(bundle);
        startActivityForResult(i, 0);
    } else if (resultCode == Activity.RESULT_CANCELED && data != null) {
        Bundle bundle = data.getExtras();
        ((HomeActivity) getActivity()).showError(bundle.getString("error"), false);
    } else if (resultCode == Activity.RESULT_CANCELED
            && ((FriendSmashApplication) getActivity().getApplication())
                    .getGameFragmentFBRequestError() != null) {
        ((HomeActivity) getActivity()).handleError(
                ((FriendSmashApplication) getActivity().getApplication()).getGameFragmentFBRequestError(),
                false);
        ((FriendSmashApplication) getActivity().getApplication()).setGameFragmentFBRequestError(null);
    }
}

From source file:com.google.android.gcm.demo.app.BluetoothHDPActivity.java

/**
 * Ensures user has turned on Bluetooth on the Android device.
 *///from   w w  w.j a v  a2 s .  c  o m
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_ENABLE_BT:
        if (resultCode == Activity.RESULT_OK) {
            initialize();
        } else {
            finish();
            return;
        }
    }
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.EditFragment.java

/**
 * Overriden method from Fragment. Sets the image and thumbnail in the comment being
 * edited to the user selected image. Is called automatically after the user
 * returns from selecting an image from either the camera or photo gallery.
 * //from  www. ja  v a 2  s.  c om
 * @param requestCode The request code supplied to startActivityForResult.
 * @param resultCode The result code returned by the activity.
 * @param data The data returned by the activity.
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Bitmap image = null;
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == ImageHelper.REQUEST_CAMERA) {
            Bitmap imageBitmap = null;
            try {
                imageBitmap = BitmapFactory.decodeStream(
                        getActivity().getContentResolver().openInputStream(Uri.fromFile(imageFile)));
            } catch (FileNotFoundException e) {
                Toaster.toastShort("Error. Could not load image.");
            }
            image = scaleImage(imageBitmap);
        } else if (requestCode == ImageHelper.REQUEST_GALLERY) {
            Bitmap imageBitmap = null;
            try {
                imageBitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(),
                        data.getData());
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            image = scaleImage(imageBitmap);
        }
    }
    editComment.setImage(image);
    Bitmap imageThumb = ThumbnailUtils.extractThumbnail(image, 100, 100);
    editComment.setImageThumb(imageThumb);
}

From source file:de.stadtrallye.rallyesoft.model.pictures.PictureManager.java

public Picture onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(THIS, "Received ActivityResult: Req: " + requestCode + ", res: " + resultCode + ", Intent: " + data);
    if (resultCode == Activity.RESULT_OK) {
        if (unconfirmed == null) {
            Log.e(THIS, "No picture requested");
            throw new UnsupportedOperationException("uncomfirmed == null, should not have happened");
        }//from   ww w .  j  a v a  2  s .com
        Uri uri = null;
        //It can either be returned with the intent parameter:
        if (data != null) {
            uri = data.getData();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                takePersistableUriPermissionApi19(data, uri);
            }
            pickedPicture(uri);
        } else {//else we use the saved value
            tookPicture();
        }

        return unconfirmed;
    } else {
        Log.v(THIS, "Negative result code");
        return null;
    }
}

From source file:app.park.com.bluetooth.BluetoothFragment.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  o m
        }
        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
            setupBT();
        } 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:edu.asu.msse.sgowdru.moviemediaplayerrpc.SearchMovie.java

public void addButtonClicked(View view) {
    //Read all the fields
    String title = info[1].getText().toString();
    String genre = info[2].getText().toString();
    String year = info[3].getText().toString();
    String actors = info[4].getText().toString();
    String dd = dropdown.getSelectedItem().toString();

    //If there are multiple genre for a movie, get the first genre and add the movie under it
    //If the first genre is not in local types of genre go to subsequent genre and check if that is there and so on
    //If no genre is present, add it under Action Genre
    String movieGenre[] = genre.trim().split(",");

    List<String> mov = Arrays.asList(movieGenre);
    List<String> ourGenre = Arrays.asList(movieGenre);
    boolean flag = false;
    for (String str : mov) {
        if (ourGenre.contains(str)) {
            genre = str;//from  www  .java2  s .com
            flag = true;
            break;
        }
    }
    if (!flag)
        genre = "Action";

    //Execute the Sqlite query to insert into local DB
    try {
        if (videoFile == null)
            crsDB.execSQL("Insert into Movies (Title, Years, Rated, Genre, Actors) VALUES('" + title + "', '"
                    + year + "', '" + dd + "', '" + genre + "', '" + actors + "');");
        else
            crsDB.execSQL("Insert into Movies (Title, Years, Rated, Genre, Actors, VideoFile) VALUES('" + title
                    + "', '" + year + "', '" + dd + "', '" + genre + "', '" + actors + "', '" + videoFile
                    + "');");

    } catch (Exception e) {
        android.util.Log.w(getClass().getSimpleName(), e.getMessage());
    }

    //Go back
    Intent i = new Intent(this, MainActivity.class);
    startActivity(i);
    setResult(Activity.RESULT_OK, intent);
    finish();
}

From source file:com.example.android.wearable.mjpegviewwear.MainActivity.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_SETTINGS:
        if (resultCode == Activity.RESULT_OK) {
            mWidth = data.getIntExtra("width", mWidth);
            mHeight = data.getIntExtra("height", mHeight);
            mIp_ad1 = data.getIntExtra("ip_ad1", mIp_ad1);
            mIp_ad2 = data.getIntExtra("ip_ad2", mIp_ad2);
            mIp_ad3 = data.getIntExtra("ip_ad3", mIp_ad3);
            mIp_ad4 = data.getIntExtra("ip_ad4", mIp_ad4);
            mIp_port = data.getIntExtra("ip_port", mIp_port);
            mIp_command = data.getStringExtra("ip_command");
            mFrameSkip = data.getIntExtra("frameSkip", mFrameSkip);

            if (mMv != null) {
                mMv.setResolution(mWidth, mHeight);
                mMv.setFrameSkip(mFrameSkip);
            }//from   ww  w  .  j av a 2s  . co  m
            SharedPreferences preferences = getSharedPreferences("SAVED_VALUES", MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putInt("width", mWidth);
            editor.putInt("height", mHeight);
            editor.putInt("ip_ad1", mIp_ad1);
            editor.putInt("ip_ad2", mIp_ad2);
            editor.putInt("ip_ad3", mIp_ad3);
            editor.putInt("ip_ad4", mIp_ad4);
            editor.putInt("ip_port", mIp_port);
            editor.putString("ip_command", mIp_command);
            editor.putInt("frameSkip", mFrameSkip);

            editor.commit();

            new RestartApp().execute();
        }
        break;
    }
}

From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case MapActivityBase.RC_GEOCODER:
        if (resultCode == Activity.RESULT_OK) {
            double lat = data.getDoubleExtra("lat", Double.NaN);
            double lon = data.getDoubleExtra("lon", Double.NaN);
            if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
                this.restoreMapState(null, lon, lat, null);
            }//ww w .j  av  a 2  s . c  om
        }
        break;
    case MapActivityBase.RC_PREFERENCES:
        this.restart();
        break;
    }
}