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:it.feio.android.omninotes.ListFragment.java

@Override
public// Used to show a Crouton dialog after saved (or tried to) a note
void onActivityResult(int requestCode, final int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    switch (requestCode) {
    case REQUEST_CODE_CATEGORY:
        // Dialog retarded to give time to activity's views of being completely initialized
        // The dialog style is choosen depending on result code
        switch (resultCode) {
        case Activity.RESULT_OK:
            mainActivity.showMessage(R.string.category_saved, ONStyle.CONFIRM);
            EventBus.getDefault().post(new CategoriesUpdatedEvent());
            break;
        case Activity.RESULT_FIRST_USER:
            mainActivity.showMessage(R.string.category_deleted, ONStyle.ALERT);
            break;
        default:/*from   w  w w.j a v  a2 s.  co  m*/
            break;
        }

        break;

    case REQUEST_CODE_CATEGORY_NOTES:
        if (intent != null) {
            Category tag = intent.getParcelableExtra(Constants.INTENT_CATEGORY);
            categorizeNotesExecute(tag);
        }
        break;

    case REQUEST_CODE_ADD_ALARMS:
        list.clearChoices();
        selectedNotes.clear();
        finishActionMode();
        list.invalidateViews();
        break;

    default:
        break;
    }

}

From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java

private void handleSpeechRecognitionActivityResult(int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK && null != data) {
        ArrayList<String> guesses = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        notifySpeechRecognitionListeners(guesses);
    }/*from   w  w w .  j  a v a2s .c o m*/
}

From source file:com.example.carsharing.ShortWayActivity.java

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

    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
        case 1: {
            StartPointMapName = data.getStringExtra(getString(R.string.dbstring_PlaceMapName));
            StartPointUserName = data.getStringExtra(getString(R.string.dbstring_PlaceUserName));
            startplace_longitude = Float.valueOf(data.getStringExtra(getString(R.string.dbstring_longitude)));
            startplace_latitude = Float.valueOf(data.getStringExtra(getString(R.string.dbstring_latitude)));

            startplace.setText(StartPointUserName + "," + StartPointMapName);
            Log.w("STintent", String.valueOf(startplace_longitude));
            Log.w("STintent", String.valueOf(startplace_latitude));
            Log.w("MapName", StartPointMapName);

            // //from  w ww  . j  a  va2  s .c  om

            if (Pointisliked(StartPointMapName)) {
                star1.setImageResource(R.drawable.ic_action_important);
            } else {
                star1.setImageResource(R.drawable.ic_action_not_important);
            }

            // end
            bstart = true;
            break;

        }
        case 2: {

            EndPointMapName = data.getStringExtra(getString(R.string.dbstring_PlaceMapName));
            EndPointUserName = data.getStringExtra(getString(R.string.dbstring_PlaceUserName));
            destination_longitude = Float.valueOf(data.getStringExtra(getString(R.string.dbstring_longitude)));
            destination_latitude = Float.valueOf(data.getStringExtra(getString(R.string.dbstring_latitude)));

            endplace.setText(EndPointUserName + "," + EndPointMapName);
            Log.w("ENDintent", String.valueOf(destination_longitude));
            Log.w("ENDintent", String.valueOf(destination_latitude));

            // 

            if (Pointisliked(EndPointMapName)) {
                star2.setImageResource(R.drawable.ic_action_important);
            } else {
                star2.setImageResource(R.drawable.ic_action_not_important);
            }

            // end

            bend = true;
            break;
        }

        }

    }

    // switch (requestCode) {
    // case 1:
    // if (resultCode == Activity.RESULT_OK) {
    // String storeadd = data.getExtras().getString("storeadd");
    // String storedet = data.getExtras().getString("storedet");
    // String historyadd = data.getExtras().getString("historyadd");
    // String historydet = data.getExtras().getString("historydet");
    // if (storeadd != null && !storeadd.isEmpty()) {
    // startplace.setText(storeadd + "," + storedet);
    // bstart = true;
    // confirm();
    // } else if (historyadd != null && !historyadd.isEmpty()) {
    // startplace.setText(historyadd + "," + historydet);
    // bstart = true;
    // confirm();
    // }
    // }
    // case 2:
    // if (resultCode == Activity.RESULT_OK) {
    // String storeadd = data.getExtras().getString("storeadd");
    // String storedet = data.getExtras().getString("storedet");
    // String historyadd = data.getExtras().getString("historyadd");
    // String historydet = data.getExtras().getString("historydet");
    // if (storeadd != null && !storeadd.isEmpty()) {
    // endplace.setText(storeadd + "," + storedet);
    // bend = true;
    // confirm();
    // } else if (historyadd != null && !historyadd.isEmpty()) {
    // endplace.setText(historyadd + "," + historydet);
    // bend = true;
    // confirm();
    // }
    // }
    //
    // }
}

From source file:com.dycody.android.idealnote.ListFragment.java

@Override
public// Used to show a Crouton dialog after saved (or tried to) a note
void onActivityResult(int requestCode, final int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    switch (requestCode) {
    case REQUEST_CODE_CATEGORY:
        // Dialog retarded to give time to activity's views of being completely initialized
        // The dialog style is choosen depending on result code
        switch (resultCode) {
        case Activity.RESULT_OK:
            Toast.makeText(getActivity(), R.string.category_saved, Toast.LENGTH_SHORT).show();
            //mainActivity.showMessage(R.string.category_saved, ONStyle.CONFIRM);
            EventBus.getDefault().post(new CategoriesUpdatedEvent());
            break;
        case Activity.RESULT_FIRST_USER:
            Toast.makeText(getActivity(), R.string.category_deleted, Toast.LENGTH_SHORT).show();
            //mainActivity.showMessage(R.string.category_deleted, ONStyle.ALERT);
            break;
        default:/* w  w w  . j a  v a 2 s  . c o  m*/
            break;
        }

        break;

    case REQUEST_CODE_CATEGORY_NOTES:
        if (intent != null) {
            Category tag = intent.getParcelableExtra(Constants.INTENT_CATEGORY);
            categorizeNotesExecute(tag);
        }
        break;

    case REQUEST_CODE_ADD_ALARMS:
        list.clearChoices();
        selectedNotes.clear();
        finishActionMode();
        list.invalidateViews();
        break;

    default:
        break;
    }

}

From source file:com.stikyhive.stikyhive.ChattingActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i(TAG, " ON ACTivyiy result");
    super.onActivityResult(requestCode, resultCode, data);
    Log.i("Result code ", " ^^ " + requestCode);
    if (requestCode == FILE_SELECT_CODE && resultCode == RESULT_OK) {
        Log.i(TAG, " ON ACTivyiy result ^^ 2");
        // Get the Uri of the selected file
        Uri uri = data.getData();/*from   w ww  . ja  va 2 s .c  om*/
        Log.d("TAG", "File Uri: " + uri.toString());
        // Get the path
        String path;
        try {
            calcualteTodayDate();
            path = getPath(this, uri);
            documentFile = new File(path);

            String extension = "";
            int index = documentFile.getName().lastIndexOf(".");
            if (index != -1) {
                extension = documentFile.getName().substring(index + 1);
            }
            Bitmap bmImg = BitmapFactory.decodeFile(path);
            //   Bitmap resBm = getResizedBitmap(bmImg, 500);
            adapter.add(new StikyChat("", "<img", false, timeSend, "file" + path, 0, 0, "", "", "", null,
                    documentFile.getPath()));
            adapter.notifyDataSetChanged();
            lv.setSelection(adapter.getCount() - 1);
            Log.i("Document File ", " %%%% " + documentFile.getAbsolutePath());
            upLoadServerUri = getApplicationContext().getResources().getString(R.string.url)
                    + "/androidstikyhive/filetransfer.php?fromStikyBee=" + pref.getString("stkid", "")
                    + "&toStikyBee=" + recipientStkid + "&message=photo" + "&extension=" + extension
                    + "&type=file" + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url="
                    + URLEncoder.encode(getResources().getString(R.string.url));
            new Thread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    int serverResponseCode = uploadFile(documentFile);
                    if (serverResponseCode == 200) {
                        Log.i("Success", " is done! ");
                        flagChatting = false;
                        flagTransfer = true;
                        messageServer = "<img";
                        msg = "File transfer.";
                        recipientStkidGCM = recipientStkid;
                        new regTask().execute("GCM");
                        new regTask2().execute("Last Message!");
                    }
                }
            }).start();
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else if (resultCode == Activity.RESULT_OK && requestCode == GALLERY_ACTIVITY_CODE) {
        Log.i(TAG, " Gallery is clicked..");
        calcualteTodayDate();
        imagePath = data.getStringExtra("picturePath");
        SDFile1 = new File(imagePath);

        String extension = "";
        int index = SDFile1.getName().lastIndexOf(".");
        if (index != -1) {
            extension = SDFile1.getName().substring(index + 1);
        }
        Bitmap bmImg = BitmapFactory.decodeFile(imagePath);
        Bitmap resBm = getResizedBitmap(bmImg, 500);
        adapter.add(new StikyChat("", "<img", false, timeSend, "bitmap" + imagePath, 0, 0, "", "", "", resBm,
                SDFile1.getPath()));
        adapter.notifyDataSetChanged();
        lv.setSelection(adapter.getCount() - 1);
        Log.i("SDFile ", " $$$ " + SDFile1.getAbsolutePath());
        upLoadServerUri = getApplicationContext().getResources().getString(R.string.url)
                + "/androidstikyhive/filetransfer.php?fromStikyBee=" + pref.getString("stkid", "")
                + "&toStikyBee=" + recipientStkid + "&message=photo" + "&extension=" + extension + "&type=image"
                + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url="
                + URLEncoder.encode(getResources().getString(R.string.url));
        new Thread(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                int serverResponseCode = uploadFile(SDFile1);
                if (serverResponseCode == 200) {
                    Log.i("Success", " is done! ");
                    flagChatting = false;
                    flagTransfer = true;
                    messageServer = "<img";
                    msg = "Image Transfer";
                    recipientStkidGCM = recipientStkid;
                    new regTask().execute("GCM");
                    new regTask2().execute("Last Message!");
                }
            }
        }).start();
        //performCrop(picturePath);
    } else if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
        convertImageUriToFile(imageUri, this);
        SDFile1 = new File(imagePath);

        String extension = "";
        int index = SDFile1.getName().lastIndexOf(".");
        if (index != -1) {
            extension = SDFile1.getName().substring(index + 1);
        }
        Bitmap bmImg = BitmapFactory.decodeFile(imagePath);
        Bitmap resBm = getResizedBitmap(bmImg, 500);
        adapter.add(new StikyChat("", "<img", false, timeSend, "bitmap" + imagePath, 0, 0, "", "", "", resBm,
                SDFile1.getPath()));
        adapter.notifyDataSetChanged();
        lv.setSelection(adapter.getCount() - 1);
        Log.i("SDFile ", " $$$ " + SDFile1.getAbsolutePath());
        upLoadServerUri = getApplicationContext().getResources().getString(R.string.url)
                + "/androidstikyhive/filetransfer.php?fromStikyBee=" + pref.getString("stkid", "")
                + "&toStikyBee=" + recipientStkid + "&message=photo" + "&extension=" + extension + "&type=image"
                + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url="
                + URLEncoder.encode(getResources().getString(R.string.url));
        new Thread(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                int serverResponseCode = uploadFile(SDFile1);
                if (serverResponseCode == 200) {
                    Log.i("Success", " is done! ");
                    flagChatting = false;
                    flagTransfer = true;
                    messageServer = "<img";
                    msg = "Image Transfer";
                    recipientStkidGCM = recipientStkid;
                    new regTask().execute("GCM");
                    new regTask2().execute("Last Message!");
                }
            }
        }).start();
    }
}

From source file:gc.david.dfm.ui.MainActivity.java

/**
 * Handle results returned to this Activity by other Activities started with
 * startActivityForResult(). In particular, the method onConnectionFailed()
 * in LocationUpdateRemover and LocationUpdateRequester may call
 * startResolutionForResult() to start an Activity that handles Google Play
 * services problems. The result of this call returns here, to
 * onActivityResult.//from w  w  w .  j  a  va  2 s.c  o  m
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    Mint.leaveBreadcrumb("MainActivity::onActivityResult");

    // 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:
            // 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:com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == FilePickerConst.REQUEST_CODE_PHOTO && resultCode == Activity.RESULT_OK) {
        if (data == null) {
            showError(getString(R.string.chat_error_failed_open_picture));
            return;
        }/*  w  w  w.  j  ava  2 s  .  com*/
        ArrayList<String> paths = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA);
        if (paths.size() > 0) {
            sendFile(new File(paths.get(0)));
        }
    } else if (requestCode == FilePickerConst.REQUEST_CODE_DOC && resultCode == Activity.RESULT_OK) {
        if (data == null) {
            showError(getString(R.string.chat_error_failed_open_file));
            return;
        }
        ArrayList<String> paths = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS);
        if (paths.size() > 0) {
            sendFile(new File(paths.get(0)));
        }
    } else if (requestCode == TAKE_PICTURE_REQUEST && resultCode == Activity.RESULT_OK) {
        try {
            sendFile(QiscusFileUtil.from(Uri.parse(QiscusCacheManager.getInstance().getLastImagePath())));
        } catch (Exception e) {
            showError(getString(R.string.chat_error_failed_read_picture));
            e.printStackTrace();
        }
    }
}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

private void onFinished(Uri... uris) {
    Log.d(TAG, "onFinished() " + Arrays.toString(uris));

    final Intent intent = new Intent();
    if (uris.length == 1) {
        intent.setData(uris[0]);/*from w  w  w  . j a  va 2s  . c  o  m*/
    } else if (uris.length > 1) {
        final ClipData clipData = new ClipData(null, mState.acceptMimes, new ClipData.Item(uris[0]));
        for (int i = 1; i < uris.length; i++) {
            clipData.addItem(new ClipData.Item(uris[i]));
        }
        intent.setClipData(clipData);
    }

    if (mState.action == ACTION_GET_CONTENT) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
    }

    setResult(Activity.RESULT_OK, intent);
    finish();
}

From source file:ac.robinson.paperchains.PaperChainsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    switch (requestCode) {
    case SOUNDCLOUD_LOGIN_RESULT:
        if (resultCode == Activity.RESULT_OK && data != null) {
            String token = data.getStringExtra(SoundCloudLoginActivity.ACCESS_TOKEN_RESULT);
            if (!TextUtils.isEmpty(token)) {
                setSoundCloudAccessToken(token);
                saveAudio(); // try again now that we have a login token
            } else {
                audioSaveFailed(R.string.soundcloud_login_failed);
            }//from  w  ww. j  ava2 s . co m
        } else {
            audioSaveFailed(R.string.soundcloud_login_failed);
        }
        break;

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

From source file:com.dwdesign.tweetings.activity.ComposeActivity.java

protected void splitTweets() {
    String text = mEditText != null ? parseString(mEditText.getText()) : null;
    String[] chunks = text.split("\\s+");
    String replyTo = null;//www.  j ava 2 s .c o  m
    if (chunks.length >= 1) {
        final String firstWord = chunks[0];
        final char firstCharacter = firstWord.charAt(0);
        if (Character.toString(firstCharacter).equals("@")) {
            replyTo = firstWord;
        }
    }
    String currentPart = "";
    tweetParts = new ArrayList<String>();
    for (final String word : chunks) {
        int checkLength = 120;
        if (tweetParts.size() > 1 && replyTo != null) {
            checkLength = 120 - replyTo.length() + 1;
        }
        if (currentPart.length() + word.length() + 1 > checkLength) {
            if (tweetParts.size() >= 1 && replyTo != null) {
                tweetParts.add(replyTo + " " + currentPart);
            } else {
                tweetParts.add(currentPart);
            }
            currentPart = "";
        }
        if (currentPart.equals("")) {
            currentPart = word;
        } else {
            currentPart = currentPart + " " + word;
        }

    }
    if (!currentPart.equals("")) {
        if (tweetParts.size() >= 1 && replyTo != null) {
            tweetParts.add(replyTo + " " + currentPart);
        } else {
            tweetParts.add(currentPart);
        }
    }
    if (tweetParts.size() >= 1) {
        for (int i = tweetParts.size(); i > 0; i--) {
            String part = tweetParts.get(i - 1);
            String postString = part + " (" + getString(R.string.split_part) + " " + Integer.toString(i) + ")";
            final boolean attach_location = mPreferences.getBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false);
            final boolean has_media = (mIsImageAttached || mIsPhotoAttached) && mImageUri != null;
            mService.updateStatus(mAccountIds, postString, attach_location ? mRecentLocation : null, mImageUri,
                    mInReplyToStatusId, has_media && mIsPossiblySensitive,
                    mIsPhotoAttached && !mIsImageAttached);
        }
        setResult(Activity.RESULT_OK);
        finish();
    }
}