Example usage for android.app Activity RESULT_CANCELED

List of usage examples for android.app Activity RESULT_CANCELED

Introduction

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

Prototype

int RESULT_CANCELED

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

Click Source Link

Document

Standard activity result: operation canceled.

Usage

From source file:com.orbar.pxdemo.ImageView.FivePXImageFragment.java

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

    if (requestCode == 1) {

        if (resultCode == Activity.RESULT_OK) {
            //boolean result=data.getBooleanExtra("result", false);     

            if (getActivity() instanceof MainActivity) {
                ((MainActivity) getActivity()).onSuccessLogin();
            }/*  w  w w  .j ava2s  . c  om*/

            if (reason == LOGGING_REASON.FAVORITE) {

                processFavorite();
            }

            if (reason == LOGGING_REASON.LIKE) {

                processLike();
            }

            if (reason == LOGGING_REASON.COMMENT) {

                submitComment();
            }

            // The comment count, Like count, or the Favorite count (and color) will change.
            mLoadImageDetailsList = new LoadImageDetailsList(getActivity(), mFiveZeroZeroImageAPIBuilder,
                    mLoginManager, mFiveZeroZeroImageBean);
            mLoadImageDetailsList.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
        if (resultCode == Activity.RESULT_CANCELED) {
            // Do Nothing, no need to process whatever triggered the login task
        }
    }
}

From source file:com.haibison.android.anhuu.FragmentFiles.java

/**
 * As the name means...//  w  ww . jav a 2s .  co  m
 */
private void showCannotConnectToServiceAndWaitForTheUserToFinish() {
    Dlg.showError(getActivity(), R.string.anhuu_f5be488d_msg_cannot_connect_to_file_provider_service,
            new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    getActivity().setResult(Activity.RESULT_CANCELED);
                    getActivity().finish();
                }// onCancel()
            });
}

From source file:com.trk.aboutme.facebook.Session.java

private void handleAuthorizationResult(int resultCode, AuthorizationClient.Result result) {
    AccessToken newToken = null;//w  w w  .ja  v  a  2 s.  c o  m
    Exception exception = null;
    if (resultCode == Activity.RESULT_OK) {
        if (result.code == AuthorizationClient.Result.Code.SUCCESS) {
            newToken = result.token;
        } else {
            exception = new FacebookAuthorizationException(result.errorMessage);
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        exception = new FacebookOperationCanceledException(result.errorMessage);
    }

    authorizationClient = null;
    finishAuthOrReauth(newToken, exception);
}

From source file:com.trk.aboutme.facebook.Session.java

private boolean tryLegacyAuth(final AuthorizationRequest request) {
    authorizationClient = new AuthorizationClient();
    authorizationClient.setOnCompletedListener(new AuthorizationClient.OnCompletedListener() {
        @Override/*from  ww  w  .  j  a v  a 2s  . c o  m*/
        public void onCompleted(AuthorizationClient.Result result) {
            int activityResult;
            if (result.code == AuthorizationClient.Result.Code.CANCEL) {
                activityResult = Activity.RESULT_CANCELED;
            } else {
                activityResult = Activity.RESULT_OK;
            }
            handleAuthorizationResult(activityResult, result);
        }
    });
    authorizationClient.setContext(getStaticContext());
    authorizationClient.startOrContinueAuth(request.getAuthorizationClientRequest());

    return true;
}

From source file:org.sirimangalo.meditationplus.ActivityMain.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == LOGIN_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            username = data.getStringExtra("username");
            password = data.getStringExtra("password");
            String method = data.getStringExtra("method");
            if (method.equals("login"))
                doLogin();/* w  w w.  ja  v  a2s.c  om*/
            else if (method.equals("register"))
                doRegister();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            finish();
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.dmsl.anyplace.UnifiedNavigationActivity.java

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

    switch (requestCode) {
    case LOCATION_CONNECTION_FAILURE_RESOLUTION_REQUEST:
        // If the result code is Activity.RESULT_OK, try to connect again
        switch (resultCode) {
        case Activity.RESULT_OK:
            // Try the request again
            // TODO - check google developers documentation again
            // and implement it correctly
        }/*from   w w w  .j av a  2 s  .c o  m*/

        break;
    case SEARCH_POI_ACTIVITY_RESULT:
        if (resultCode == Activity.RESULT_OK) {
            // search activity finished OK
            if (data == null)
                return;
            // PoisModel poi_to = (PoisModel)
            // data.getSerializableExtra("pmodel");
            // startNavigationTask(poi_to);

            IPoisClass place = (IPoisClass) data.getSerializableExtra("ianyplace");
            handleSearchPlaceSelection(place);

        } else if (resultCode == Activity.RESULT_CANCELED) {
            // CANCELLED
            if (data == null)
                return;
            String msg = (String) data.getSerializableExtra("message");
            if (msg != null)
                Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
        }
        break;
    case SELECT_PLACE_ACTIVITY_RESULT:
        if (resultCode == Activity.RESULT_OK) {
            if (data == null)
                return;

            String fpf = data.getStringExtra("floor_plan_path");
            if (fpf == null) {
                Toast.makeText(getBaseContext(), "You haven't selected both building and floor...!",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            try {
                BuildingModel b = mAnyplaceCache.getSpinnerBuildings().get(data.getIntExtra("bmodel", 0));
                FloorModel f = b.getFloors().get(data.getIntExtra("fmodel", 0));
                selectPlaceActivityResult(b, f);
            } catch (Exception ex) {
                Toast.makeText(getBaseContext(), "You haven't selected both building and floor...!",
                        Toast.LENGTH_SHORT).show();
            }

        } else if (resultCode == Activity.RESULT_CANCELED) {
            // CANCELLED
            if (data == null)
                return;
            String msg = (String) data.getSerializableExtra("message");
            if (msg != null)
                Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
        }
        break;
    case PREFERENCES_ACTIVITY_RESULT:
        if (resultCode == RESULT_OK) {
            AnyplacePrefs.Action result = (Action) data.getSerializableExtra("action");

            switch (result) {
            case REFRESH_BUILDING:

                if (!userData.isFloorSelected()) {
                    Toast.makeText(getBaseContext(), "Load a map before performing this action!",
                            Toast.LENGTH_SHORT).show();
                    break;
                }

                if (progressBar.getVisibility() == View.VISIBLE) {
                    Toast.makeText(getBaseContext(), "Building Loading in progress. Please Wait!",
                            Toast.LENGTH_SHORT).show();
                    break;
                }

                try {

                    final BuildingModel b = userData.getSelectedBuilding();
                    // clear_floorplans
                    File floorsRoot = new File(AnyplaceUtils.getFloorPlansRootFolder(this), b.buid);
                    // clear radiomaps
                    File radiomapsRoot = AnyplaceUtils.getRadioMapsRootFolder(this);
                    final String[] radiomaps = radiomapsRoot.list(new FilenameFilter() {

                        @Override
                        public boolean accept(File dir, String filename) {
                            if (filename.startsWith(b.buid))
                                return true;
                            else
                                return false;
                        }
                    });
                    for (int i = 0; i < radiomaps.length; i++) {
                        radiomaps[i] = radiomapsRoot.getAbsolutePath() + File.separator + radiomaps[i];
                    }

                    floorSelector.Stop();
                    disableAnyplaceTracker();
                    DeleteFolderBackgroundTask task = new DeleteFolderBackgroundTask(
                            new DeleteFolderBackgroundTask.DeleteFolderBackgroundTaskListener() {

                                @Override
                                public void onSuccess() {

                                    // clear any markers that might have already
                                    // been added to the map
                                    visiblePois.clearAll();
                                    // clear and resets the cached POIS inside
                                    // AnyplaceCache
                                    mAnyplaceCache.setPois(new HashMap<String, PoisModel>(), "");
                                    mAnyplaceCache.fetchAllFloorsRadiomapReset();

                                    bypassSelectBuildingActivity(b, b.getSelectedFloor());

                                }
                            }, UnifiedNavigationActivity.this, true);
                    task.setFiles(floorsRoot);
                    task.setFiles(radiomaps);
                    task.execute();
                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }
            break;
        }
        break;
    }
}

From source file:com.annanovas.bestprice.DashBoardEditActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SELECT_FILE) {
        if (resultCode == Activity.RESULT_OK) {
            Bitmap selectedImage = null;
            try {
                selectedImage = decodeUri(data.getData());
                selectedImage = imageProcess(selectedImage);
                if (selectedImage != null) {
                    new ImageString(selectedImage).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    showLog("Bitmap Size " + selectedImage.getHeight() + "*" + selectedImage.getWidth());
                    userImage.setImageBitmap(selectedImage);
                }//from ww w .  java  2  s.  co  m
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    } else if (requestCode == REQUEST_CAMERA) {
        if (resultCode == Activity.RESULT_OK) {
            File file = new File(imageUri);
            Bitmap selectedImage = decodeSampledBitmapFromFile(file.getAbsolutePath(), 1000, 1000);
            selectedImage = imageProcess(selectedImage);
            if (selectedImage != null) {
                new ImageString(selectedImage).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                showLog("Bitmap Size " + selectedImage.getHeight() + "*" + selectedImage.getWidth());
                userImage.setImageBitmap(selectedImage);
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            // showLog("Canceled");
            File file = new File(imageUri);
            file.delete();
        }
    }
}

From source file:com.money.manager.ex.transactions.EditTransactionCommonFunctions.java

private void cancelActivity() {
    getActivity().setResult(Activity.RESULT_CANCELED);
    getActivity().finish();
}

From source file:com.aimfire.demo.CamcorderActivity.java

private void launchMain() {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "launchMain");

    end3dAttempt(-1);//from   w w w. j av  a2  s  .c  o m

    /*
     * set result code - "ok" here means device pairing was attempted,
     * "canceled" means it was not
     */
    if (mP2pAttempted) {
        setResult(Activity.RESULT_OK);
    } else {
        setResult(Activity.RESULT_CANCELED);
    }

    /*
     * exit out of camcorder
     */
    finish();
}

From source file:com.droid.app.fotobot.FotoBot.java

public void sendSMS(String phoneNumber, String message) {
    String SENT = "SMS_SENT";
    String DELIVERED = "SMS_DELIVERED";

    PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);

    PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);

    //---when the SMS has been sent---
    registerReceiver(new BroadcastReceiver() {
        @Override/*  www.  j  a  v a 2 s.  co  m*/
        public void onReceive(Context arg0, Intent arg1) {
            switch (getResultCode()) {
            case Activity.RESULT_OK:
                Toast.makeText(getBaseContext(), "SMS sent", Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                Toast.makeText(getBaseContext(), "Generic failure", Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_NO_SERVICE:
                Toast.makeText(getBaseContext(), "No service", Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_NULL_PDU:
                Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_RADIO_OFF:
                Toast.makeText(getBaseContext(), "Radio off", Toast.LENGTH_SHORT).show();
                break;
            }
        }
    }, new IntentFilter(SENT));

    //---when the SMS has been delivered---
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            switch (getResultCode()) {
            case Activity.RESULT_OK:
                Toast.makeText(getBaseContext(), "SMS delivered", Toast.LENGTH_SHORT).show();
                break;
            case Activity.RESULT_CANCELED:
                Toast.makeText(getBaseContext(), "SMS not delivered", Toast.LENGTH_SHORT).show();
                break;
            }
        }
    }, new IntentFilter(DELIVERED));

    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}