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: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(); }//from www . j a va 2s .com 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.dwdesign.tweetings.activity.ComposeActivity.java
protected void actuallyPost() { final String text = mEditText != null ? parseString(mEditText.getText()) : null; final boolean attach_location = mPreferences.getBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false); if (mScheduleDate != null) { mService.scheduleStatus(mScheduleDate, mAccountIds, text, attach_location ? mRecentLocation : null, mImageUri, mInReplyToStatusId, mIsPhotoAttached && !mIsImageAttached); } else if (mIsBuffer == true) { mService.bufferStatus(mAccountIds, text); } else {/* w ww .j av a2 s . co m*/ final boolean has_media = (mIsImageAttached || mIsPhotoAttached) && mImageUri != null; mService.updateStatus(mAccountIds, text, attach_location ? mRecentLocation : null, mImageUri, mInReplyToStatusId, has_media && mIsPossiblySensitive, mIsPhotoAttached && !mIsImageAttached); } setResult(Activity.RESULT_OK); finish(); }
From source file:com.tsp.clipsy.audio.RingdroidEditActivity.java
private void afterSavingRingtone(CharSequence title, String outPath, File outFile, int duration) { // Create the database record, pointing to the existing file path long fileSize = outFile.length(); String mimeType = "audio/mpeg"; String artist = "" + getResources().getText(R.string.artist_name); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, outPath); values.put(MediaStore.MediaColumns.TITLE, title.toString()); values.put(MediaStore.MediaColumns.SIZE, fileSize); values.put(MediaStore.MediaColumns.MIME_TYPE, mimeType); values.put(MediaStore.Audio.Media.ARTIST, artist); values.put(MediaStore.Audio.Media.DURATION, duration); values.put(MediaStore.Audio.Media.IS_RINGTONE, false); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); values.put(MediaStore.Audio.Media.IS_ALARM, false); values.put(MediaStore.Audio.Media.IS_MUSIC, true); // Insert it into the database Uri uri = MediaStore.Audio.Media.getContentUriForPath(outPath); final Uri newUri = getContentResolver().insert(uri, values); setResult(RESULT_OK, new Intent().setData(newUri)); // Update a preference that counts how many times we've // successfully saved a ringtone or other audio SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_SUCCESS_COUNT, successCount + 1); prefsEditor.commit();/* w ww. j a v a 2 s. c o m*/ Intent output = new Intent(); output.putExtra("path", outPath); setResult(Activity.RESULT_OK, output); Toast.makeText(this, R.string.save_success_message, Toast.LENGTH_SHORT).show(); finish(); return; }
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();/*from w ww . j a va2s . c om*/ else if (method.equals("register")) doRegister(); } else if (resultCode == Activity.RESULT_CANCELED) { finish(); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { if (requestCode == Application.ACTION_ADD_PHOTO || requestCode == Application.ACTION_TAKE_PHOTO) { /* add photo */ if (contents.size() == 5) return; Uri selectedImage;/*from www . j a va 2s . com*/ Bitmap tbm; if (requestCode == Application.ACTION_ADD_PHOTO) { selectedImage = data.getData(); tbm = getBitmapThumbnail(selectedImage); } /*else if (requestCode == Application.ACTION_TAKE_PHOTO && data != null && data.hasExtra("data")) { Bundle b = data.getExtras(); String mpath = null; Bitmap bitmap = (Bitmap) b.get("data"); try { if (tempFile == null) { File f = File.createTempFile("dcuploader_photo_", ".jpg", Environment .getDownloadCacheDirectory()); FileOutputStream fo = new FileOutputStream(f); mpath = f.getAbsolutePath(); bitmap.compress(CompressFormat.JPEG, 90, fo); fo.close(); } else { mpath = tempFile.getAbsolutePath(); tempFile = null; } } catch (IOException e) { e.printStackTrace(); return; } selectedImage = Uri.parse("file://" + mpath); tempFiles.add(mpath); tbm = getBitmapThumbnail(bitmap); bitmap.recycle(); } */else { /* take photo */ selectedImage = Uri.fromFile(tempFile); tempFiles.add(tempFile.getAbsolutePath()); tbm = getBitmapThumbnail(selectedImage); } Gallery g = (Gallery) findViewById(R.id.upload_images); int npos = 0; int pos = g.getSelectedItemPosition(); if (pos == -1 || pos == 3) { contents.add(selectedImage); bitmaps.add(tbm); if (pos == 3) npos = pos + 1; } else { contents.add(pos + 1, selectedImage); bitmaps.add(pos + 1, tbm); npos = pos + 1; } updateGallery(); updateImageButtons(); g.setSelection(npos); galleryChanged = true; } else if (requestCode == Application.ACTION_ADD_GALLERY) { /* add gallery */ DatabaseHelper db = new DatabaseHelper(ActivityUploader.this); db.setFavorites(data.getStringArrayExtra("result")); db.close(); openContextMenu(findViewById(R.id.upload_target)); } else if (requestCode == Application.ACTION_SIGN_ON) { /* when signed on, go on. */ publish(); } else if (requestCode == Application.ACTION_PREFERENCES) { /* apply preferences */ Log.d(Application.TAG, "reloading configuration..."); reloadConfigurations(); setDefaultImage(); queryLocation(formLocation); } } }
From source file:com.example.carsharing.CommuteActivity.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); // // w w w .j a va 2 s . co m 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; } } } }
From source file:com.chaqianma.jd.fragment.CompanyInfoFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case REQUEST_SDK_IMGS: if (data != null && data.getData() != null) { Uri imgUri = data.getData(); ContentResolver resolver = getActivity().getContentResolver(); String[] pojo = { MediaStore.Images.Media.DATA }; Cursor cursor = null; try { cursor = resolver.query(imgUri, pojo, null, null, null); if (cursor != null && cursor.getCount() > 0) { int colunm_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); new Thread(new BaseFragment.ImgRunable(cursor.getString(colunm_index), Constants.BUSINESS_INFO, fileType, selCompanyIdxTag, new UpdateUIHandler())) .start(); } else { JDToast.showLongText(getActivity(), ""); }//w w w . jav a 2s .co m } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } } break; case REQUEST_TAKE_PHOTO: new Thread(new BaseFragment.ImgRunable(Constants.TEMPPATH, Constants.BUSINESS_INFO, fileType, selCompanyIdxTag, new UpdateUIHandler())).start(); break; default: break; } } }
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/*from www.j a va2 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); }
From source file:cgeo.geocaching.CacheListActivity.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_IMPORT_GPX && resultCode == Activity.RESULT_OK) { // The document selected by the user won't be returned in the intent. // Instead, a URI to that document will be contained in the return intent // provided to this method as a parameter. Pull that uri using "resultData.getData()" if (data != null) { final Uri uri = data.getData(); new GPXImporter(this, listId, importGpxAttachementFinishedHandler).importGPX(uri, null, getDisplayName(uri)); }/*from w w w . ja v a 2s . c om*/ } else if (requestCode == REQUEST_CODE_IMPORT_PQ && resultCode == Activity.RESULT_OK) { if (data != null) { final Uri uri = data.getData(); new GPXImporter(this, listId, importGpxAttachementFinishedHandler).importGPX(uri, data.getType(), null); } } else if (requestCode == FilterActivity.REQUEST_SELECT_FILTER && resultCode == Activity.RESULT_OK) { final int[] filterIndex = data.getIntArrayExtra(FilterActivity.EXTRA_FILTER_RESULT); setFilter(FilterActivity.getFilterFromPosition(filterIndex[0], filterIndex[1])); } else if (requestCode == REQUEST_CODE_RESTART && resultCode == Activity.RESULT_OK) { restartActivity(); } if (type == CacheListType.OFFLINE && requestCode != REQUEST_CODE_RESTART) { refreshCurrentList(); } }
From source file:com.tdispatch.passenger.fragment.ControlCenterFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { switch (requestCode) { case Const.RequestCode.ADDRESS_SEARCH: { if (resultCode == Activity.RESULT_OK) { int type = intent.getExtras().getInt(Const.Bundle.TYPE); LocationData location = intent.getExtras().getParcelable(Const.Bundle.LOCATION); switch (type) { case SearchActivity.TYPE_PICKUP: setPickupAddress(location); break; case SearchActivity.TYPE_DROPOFF: setDropoffAddress(location); break; }/*from w ww. java 2 s .c o m*/ updateAddresses(); moveMapToLocation(location); } } break; default: { super.onActivityResult(requestCode, resultCode, intent); } break; } }