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:ca.rmen.android.networkmonitor.app.prefs.SelectFieldsActivity.java

public void onOk(@SuppressWarnings("UnusedParameters") View v) {
    Log.v(TAG, "onOk");
    SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions();
    String[] dbColumns = NetMonColumns.getColumnNames(this);
    final List<String> selectedColumns = new ArrayList<>(dbColumns.length);
    for (int i = 0; i < dbColumns.length; i++) {
        if (checkedPositions.get(i))
            selectedColumns.add(dbColumns[i]);
    }/*from  w  w w  .  j  av a2s.  c o m*/
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            NetMonPreferences.getInstance(SelectFieldsActivity.this).setSelectedColumns(selectedColumns);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            setResult(Activity.RESULT_OK);
            finish();
        }
    }.execute();
}

From source file:com.ariesmcrae.eskwela.celebtweet.MainActivity.java

/**
 * If stored Tweets are not fresh, reload them from network, Otherwise, load them from file
 */// w  w w  .j a v a  2s .  c  o  m
private void ensureData() {
    log("In ensureData(), mIsFresh:" + mIsFresh);

    if (!mIsFresh) {
        Toast.makeText(getApplicationContext(), "Downloading Tweets from Network", Toast.LENGTH_LONG).show();

        log("Issuing Toast Message");

        // Start new AsyncTask to download Tweets from network
        new DownloaderTask(this).execute(URL_LGAGA, URL_RBLACK, URL_TSWIFT);

        // Set up a BroadcastReceiver to receive an Intent when download finishes.
        mRefreshReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                log("BroadcastIntent received in MainActivity");

                if (isOrderedBroadcast()) {
                    // Check to make sure this is an ordered broadcast. 
                    // Let AsyncTask sender (DownloaderTask) know that the Intent was received by setting result code to RESULT_OK.
                    // RESULT_OK which will inform the AsyncTask that the MainActivity is active and in the foreground, and
                    // therefore, the AsyncTask should not send the user notification.
                    setResultCode(Activity.RESULT_OK);
                }
            }
        };

    } else {
        loadTweetsFromFile();
        parseJSON();
        updateFeed();
    }
}

From source file:com.bellman.bible.android.view.activity.footnoteandref.FootnoteAndRefActivity.java

public void doFinish() {
    Intent resultIntent = new Intent();
    setResult(Activity.RESULT_OK, resultIntent);
    finish();
}

From source file:com.timrae.rikaidroid.MainActivity.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_AEDICT_ANALYSIS && resultCode == Activity.RESULT_OK) {
        List<HashMap<String, String>> result = (List<HashMap<String, String>>) data
                .getSerializableExtra("result");
        StringBuilder builder = getHtmlPreamble();
        addAedictItems(builder, result);
        displayHtml(builder);/*from www  .  ja v  a2s.  c  om*/
    }
}

From source file:org.mifos.androidclient.main.AccountDetailsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (resultCode) {
    case Activity.RESULT_OK:
        runAccountDetailsTask();//w w w . jav a2  s. co  m
        break;
    case Activity.RESULT_CANCELED:
        break;
    default:
        break;
    }
}

From source file:com.whamads.nativecamera.NativeCameraLauncher.java

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    // If image available
    if (resultCode == Activity.RESULT_OK) {
        int rotate = 0;
        try {/*from w  w w .  ja  v a2  s .  c  om*/
            // Check if the image was written to
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            Bitmap bitmap = BitmapFactory.decodeFile(this.imageUri.getPath(), options);
            if (options.outWidth == -1 || options.outHeight == -1) {
                this.failPicture("Error decoding image.");
                return;
            }

            ExifHelper exif = new ExifHelper();
            exif.createInFile(this.imageUri.getPath());
            exif.readExifData();
            rotate = exif.getOrientation();
            Log.i(LOG_TAG, "Uncompressed image rotation value: " + rotate);

            exif.resetOrientation();
            exif.createOutFile(this.imageUri.getPath());
            exif.writeExifData();

            JSONObject returnObject = new JSONObject();
            returnObject.put("url", this.imageUri.toString());
            returnObject.put("rotation", rotate);

            Log.i(LOG_TAG, "Return data: " + returnObject.toString());

            PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);

            // Log.i(LOG_TAG, "Final Exif orientation value: " + exif.getOrientation());

            // Send Uri back to JavaScript for viewing image
            this.callbackContext.sendPluginResult(result);

        } catch (IOException e) {
            e.printStackTrace();
            this.failPicture("Error capturing image.");
        } catch (JSONException e) {
            e.printStackTrace();
            this.failPicture("Error capturing image.");
        }
    }

    // If browse gallery clicked
    else if (resultCode == CameraActivity.BROWSE_GALLERY) {
        this.failPicture("BROWSE_GALLERY");
    }

    // If cancelled
    else if (resultCode == Activity.RESULT_CANCELED) {
        this.failPicture("Camera cancelled.");
    }

    // If something else
    else {
        this.failPicture("Did not complete!");
    }
}

From source file:com.acc.android.util.widget.adapter.ImageAdapter.java

public ImageAdapter(final Context context,
        // List<Cphoto> cPhotos,
        Gallery gallery, BitmapProviderManager bitmapProviderManager, ACCFileCallback accFileCallback,
        // boolean useOldShowImage,
        boolean useGalleryDeleteAction, boolean isBig) {
    this.context = context;
    this.gallery = gallery;
    // this.cPhotos = new ArrayList<Cphoto>();
    this.isBig = isBig;
    // if (fileDownloadManager == null) {
    // Handler fileDownloadListener = new Handler() {
    // @Override//from   w w w.  j a va  2s  .  co  m
    // public void handleMessage(final Message msg) {
    // ImageAdapter.this.notifyDataSetChanged();
    // }
    // };
    // // ;
    // fileDownloadManager = new FileDownloadManager(context,
    // fileDownloadListener);
    // }
    this.accFileCallback = accFileCallback;
    this.bitmapProviderManager = bitmapProviderManager;
    // this.gallery.setAdapter(this);
    this.gallery.setVisibility(View.GONE);
    // this.fileDownloadManager = fileDownloadManager;
    this.initGalleryAciton(
            // useOldShowImage,
            useGalleryDeleteAction);
    this.onSingleTapListener = new OnSingleTapListener() {

        @Override
        public void onSingleTap() {
            Intent intent = new Intent();
            intent.putExtras(IntentUtil.getBundle(ACCALibConstant.KEY_BUNDLE_ACC_FILE_S,
                    ImageAdapter.this.getTransImageData()));
            Activity contextActivity = (Activity) context;
            contextActivity.setResult(Activity.RESULT_OK, intent);
            contextActivity.finish();
        }
    };
    this.initImageData();
}

From source file:com.ct.speech.HintReceiver.java

/**
 * Request the supported languages/*w  w w.  jav a2s . com*/
 */
private void getSupportedLanguages() {
    // Create and launch get languages intent
    Intent intent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
    HintReceiver hintReceiver = new HintReceiver();
    hintReceiver.setSpeechRecognizer(this);
    // hintReceiver.setCallBackId(this.callbackId);
    ctx.getApplicationContext().sendOrderedBroadcast(intent, null, hintReceiver, null, Activity.RESULT_OK, null,
            null);
}

From source file:com.activiti.android.app.fragments.integration.alfresco.AlfrescoIntegrationFragment.java

public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (requestCode == 10 && resultCode == Activity.RESULT_OK) {
        String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
        Account[] accounts = AccountManager.get(getActivity())
                .getAccountsByType(AlfrescoIntegrator.ALFRESCO_ACCOUNT_TYPE);
        for (int i = 0; i < accounts.length; i++) {
            if (accountName.equals(accounts[i].name)) {
                selectedAccount = accounts[i];
                break;
            }/* w w w. j  av a2 s .  c  om*/
        }
    }
}

From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java

/**
 * Callback from ChooseLocationActivity//from  w  ww.j  a  v a 2  s.co m
 * 
 * Intent data should have latitude and longitude
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CHOOSE_LOCATION_REQUEST) {
        if (resultCode == Activity.RESULT_OK) {
            int latitudeE6 = data.getIntExtra(Open311.LATITUDE, 0);
            int longitudeE6 = data.getIntExtra(Open311.LONGITUDE, 0);

            String latitude = Double.toString(latitudeE6 / 1e6);
            String longitude = Double.toString(longitudeE6 / 1e6);
            // Display the lat/long as text for now
            // It will get replaced with the address when ReverseGeoCodingTask returns
            mLocationView.setText(String.format("%s, %s", latitude, longitude));

            mReport.add(new BasicNameValuePair(Open311.LATITUDE, latitude));
            mReport.add(new BasicNameValuePair(Open311.LONGITUDE, longitude));

            new ReverseGeocodingTask(getActivity(), mLocationView)
                    .execute(new GeoPoint(latitudeE6, longitudeE6));
        }
    }
}