List of usage examples for android.app Activity RESULT_OK
int RESULT_OK
To view the source code for android.app Activity RESULT_OK.
Click Source Link
From source file:fr.cph.stock.android.activity.EquityActivity.java
@Override public void reloadData(Portfolio portfolio) { // StockTrackerApp app = (StockTrackerApp) getApplication(); equities.clear();/*from w w w . jav a 2 s . c o m*/ equities.addAll(portfolio.getEquities()); mAdapter.notifyDataSetChanged(); lastUpdatedView.setText(portfolio.getLastUpdate()); menuItem.collapseActionView(); menuItem.setActionView(null); Intent resultIntent = new Intent(); resultIntent.putExtra("portfolio", portfolio); setResult(Activity.RESULT_OK, resultIntent); StockTrackerApp app = (StockTrackerApp) getApplication(); app.toast(); }
From source file:io.v.syncslides.DeckChooserFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_IMPORT_DECK: if (resultCode != Activity.RESULT_OK) { String errorStr = data != null && data.hasExtra(DocumentsContract.EXTRA_ERROR) ? data.getStringExtra(DocumentsContract.EXTRA_ERROR) : ""; toast("Error selecting deck to import " + errorStr); break; }// w w w. j a v a 2s .c om Uri uri = data.getData(); DeckImporter importer = new DeckImporter(getActivity().getContentResolver(), DB.Singleton.get()); ListenableFuture<Void> future = importer.importDeck(DocumentFile.fromTreeUri(getContext(), uri)); Futures.addCallback(future, new FutureCallback<Void>() { @Override public void onSuccess(Void result) { toast("Import complete"); } @Override public void onFailure(Throwable t) { toast("Import failed: " + t.getMessage()); } }); break; } }
From source file:com.oe.phonegap.plugins.AutoRecordVideo.java
/** * Called when the video view exits./*from w w w .j a va2 s . c om*/ * * @param requestCode 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"). * @throws JSONException */ public void onActivityResult(int requestCode, int resultCode, final Intent intent) { // Result received okay if (resultCode == Activity.RESULT_OK) { // An audio clip was requested if (requestCode == CAPTURE_VIDEO) { final AutoRecordVideo that = this; Runnable captureVideo = new Runnable() { @Override public void run() { Uri data = null; if (intent != null) { // Get the uri of the video clip data = intent.getData(); } if (data == null) { File movie = new File(getTempDirectoryPath(), "AutoRecordVideo.avi"); OELog.d("data null " + movie.toURI()); data = Uri.fromFile(movie); } // create a file object from the uri if (data == null) { that.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null")); } else { result = createMediaFile(data); OELog.d("Camera success" + data); that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } } }; this.cordova.getThreadPool().execute(captureVideo); } } // If canceled else if (resultCode == Activity.RESULT_CANCELED) { // If we have partial results send them back to the user if (result != null) { this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } // user canceled the action else { this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled.")); } } // If something else else { // If we have partial results send them back to the user if (result != null) { this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } // something bad happened else { this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!")); } } }
From source file:com.example.snapcacheexample.SelectionFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REAUTH_ACTIVITY_CODE) { uiHelper.onActivityResult(requestCode, resultCode, data); } else if (resultCode == Activity.RESULT_OK && requestCode >= 0 && requestCode < listElements.size()) { listElements.get(requestCode).onActivityResult(data); }//ww w. ja v a 2 s . c om }
From source file:export.GooglePlus.java
@Override public Status getAuthResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { try {/*w w w.j a v a2 s . com*/ String authConfig = data.getStringExtra(DB.ACCOUNT.AUTH_CONFIG); JSONObject tmp = new JSONObject(authConfig); access_token = tmp.getString("access_token"); refresh_token = tmp.optString("refresh_token", null); expire_time = tmp.getLong("expires_in"); token_now = System.currentTimeMillis(); return Status.OK; } catch (Exception ex) { ex.printStackTrace(); } } return Status.ERROR; }
From source file:org.runnerup.export.RunningAHEADSynchronizer.java
@Override public Status getAuthResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { String authConfig = data.getStringExtra(DB.ACCOUNT.AUTH_CONFIG); try {/*from ww w. ja v a 2s . c o m*/ access_token = new JSONObject(authConfig).getString("access_token"); return Status.OK; } catch (JSONException e) { e.printStackTrace(); } } return Status.ERROR; }
From source file:com.remcob00.cordova.youtube.YouTube.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (requestCode == 23100010 && resultCode != Activity.RESULT_OK) { YouTubeInitializationResult result = YouTubeStandalonePlayer.getReturnedInitializationResult(intent); if (result.isUserRecoverableError()) { result.getErrorDialog(cordova.getActivity(), 0).show(); }// w ww . j a v a 2 s .c o m } }
From source file:com.rei.lolchat.ui.Login.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == LOGIN_REQUEST_CODE) { mIsResult = true;//from ww w . ja v a 2 s.c o m if (resultCode == Activity.RESULT_OK) { startActivity(new Intent(this, ContactList.class)); finish(); } else if (resultCode == Activity.RESULT_CANCELED) { if (data != null) { String tmp = data.getExtras().getString("message"); Toast.makeText(Login.this, tmp, Toast.LENGTH_SHORT).show(); mTextView.setText(tmp); SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this); String server = mSettings.getString(BeemApplication.LEVEL_KEY, ""); tv_na = (TextView) findViewById(R.id.status_na); tv_eune = (TextView) findViewById(R.id.status_eune); tv_euw = (TextView) findViewById(R.id.status_euw); String text = ""; text = "<font color='#0099FF'>[US]</font> Checking..."; tv_na.setText(Html.fromHtml(text)); text = "<font color='#0099FF'>[EU-NE]</font> Checking..."; tv_eune.setText(Html.fromHtml(text)); text = "<font color='#0099FF'>[EU-W]</font> Checking..."; tv_euw.setText(Html.fromHtml(text)); loadServerStatusTask task = new loadServerStatusTask(); task.execute("na"); loadServerStatusTask task2 = new loadServerStatusTask(); task2.execute("eune"); loadServerStatusTask task3 = new loadServerStatusTask(); task3.execute("euw"); } } } }
From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationProvider.java
public void broadcastLocation(Location location) { final LocationProxy bgLocation = LocationProxy.fromAndroidLocation(location); bgLocation.setServiceProvider(config.getServiceProvider()); if (config.isDebugging()) { bgLocation.setDebug(true);//from ww w . j ava 2 s.co m persistLocation(bgLocation); } Log.d(TAG, "Broadcasting update message: " + bgLocation.toString()); try { String locStr = bgLocation.toJSONObject().toString(); Intent intent = new Intent(Constant.ACTION_FILTER); intent.putExtra(Constant.ACTION, Constant.ACTION_LOCATION_UPDATE); intent.putExtra(Constant.DATA, locStr); if (config.getUrl() != null) { Log.i(TAG, "Sending URL detail"); intent.putExtra("url", config.getUrl()); intent.putExtra("method", config.getMethod()); intent.putExtra("headers", config.getHeaders()); intent.putExtra("params", config.getParams()); } else { Log.i(TAG, "No URL defined"); } context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() { // @SuppressLint("NewApi") @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Final Result Receiver"); Bundle results = getResultExtras(true); if (results.getString(Constant.LOCATION_SENT_INDICATOR) == null) { Log.w(TAG, "Main activity seems to be killed"); if (config.getStopOnTerminate() == false) { bgLocation.setDebug(false); persistLocation(bgLocation); Log.d(TAG, "Persisting location. Reason: Main activity was killed."); } } } }, null, Activity.RESULT_OK, null, null); } catch (JSONException e) { Log.w(TAG, "Failed to broadcast location"); } }
From source file:mobisocial.musubi.ui.fragments.ChooseImageDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()).setTitle("Choose an Image...") .setItems(new String[] { "From Camera", "From Gallery" }, new DialogInterface.OnClickListener() { @SuppressWarnings("deprecation") @Override/*from w ww . j av a 2s. co m*/ public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: final Activity activity = getActivity(); Toast.makeText(activity, "Loading camera...", Toast.LENGTH_SHORT).show(); ((InstrumentedActivity) activity) .doActivityForResult(new PhotoTaker(activity, new PhotoTaker.ResultHandler() { @Override public void onResult(Uri imageUri) { Log.d(getClass().getSimpleName(), "Updating thumbnail..."); try { UriImage image = new UriImage(activity, imageUri); byte[] data = image.getResizedImageData(512, 512, PictureObj.MAX_IMAGE_SIZE / 2); // profile Bitmap sourceBitmap = BitmapFactory.decodeByteArray(data, 0, data.length); int width = sourceBitmap.getWidth(); int height = sourceBitmap.getHeight(); int cropSize = Math.min(width, height); Bitmap cropped = Bitmap.createBitmap(sourceBitmap, 0, 0, cropSize, cropSize); ByteArrayOutputStream baos = new ByteArrayOutputStream(); cropped.compress(Bitmap.CompressFormat.JPEG, 90, baos); cropped.recycle(); sourceBitmap.recycle(); Bundle bundle = new Bundle(); bundle.putByteArray(EXTRA_THUMBNAIL, baos.toByteArray()); Intent res = new Intent(); res.putExtras(bundle); getTargetFragment().onActivityResult(REQUEST_PROFILE_PICTURE, Activity.RESULT_OK, res); } catch (Throwable t) { Log.e("ViewProfile", "failed to generate thumbnail of profile", t); Toast.makeText(activity, "Profile picture capture failed. Try again.", Toast.LENGTH_SHORT).show(); } } }, 200, false)); break; case 1: Intent gallery = new Intent(Intent.ACTION_GET_CONTENT); gallery.setType("image/*"); // god damn fragments. getTargetFragment().startActivityForResult(Intent.createChooser(gallery, null), REQUEST_GALLERY_THUMBNAIL); break; } } }).create(); }