List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:cn.zsmy.akm.doctor.profile.fragment.UploadPhotoFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != -1) { return;/*from w ww. java2s.c o m*/ } Uri uri = null; if (data != null && data.getData() != null) { uri = data.getData(); } switch (requestCode) { case DOCTOR_IMAGE_PIC: if (PHOTO_CREAME == CREAME) { if (uri == null) { uri = tempUri; picturePath = SystemPhoto.getFilePathFromUri(getActivity(), uri); } } else if (PHOTO_CREAME == PHOTO) { picturePath = StringUtils.getFilePath(getActivity(), data); } break; case DOCTOR_VIDEO: // urlDatas.set(1, picturePath); // Log.i("TAG",picturePath); // if(picturePath!=null){ // loadImg.setImageBitmap(BitmapFactory.decodeFile(picturePath)); // } break; default: break; } if (picturePath != null) { Log.i("TAG", picturePath); urlDatas.set(0, picturePath); Bitmap bitmap = ImageUtils.zoomDrawable(ImageUtils.resizePhoto(getActivity(), picturePath), loadImg.getWidth(), loadImg.getHeight()); if (bitmap != null) { loadImg.setBackgroundDrawable(ImageUtils.resizePhoto(getActivity(), picturePath)); loadImg.setImageBitmap(null); // loadImg.setImageBitmap(bitmap); photoPopupWindow.dismiss(); } } }
From source file:ca.ggolda.lendit.fragments.FragChat.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { if (resultCode == RESULT_OK) { Toast.makeText(getContext(), "You're Signed In", Toast.LENGTH_SHORT).show(); } else if (resultCode == RESULT_CANCELED) { Toast.makeText(getContext(), "Sign In Canceled", Toast.LENGTH_SHORT).show(); getActivity().finish();/*from w ww. j a v a 2 s . com*/ } } else if (requestCode == RC_PHOTO_PICKER && resultCode == RESULT_OK) { Uri selectedImageUri = data.getData(); // Get a reference to store file at chat_photos/<FILENAME> StorageReference photoRef = mChatPhotosStorageReference.child(selectedImageUri.getLastPathSegment()); // Upload file to Firebase Storage photoRef.putFile(selectedImageUri).addOnSuccessListener(getActivity(), new OnSuccessListener<UploadTask.TaskSnapshot>() { public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { // When the image has successfully uploaded, we get its download URL Uri downloadUrl = taskSnapshot.getDownloadUrl(); // Set the download URL to the message box, so that the user can send it to the database InstanceMessage friendlyMessage = new InstanceMessage(null, mUsername, downloadUrl.toString()); mMessagesDatabaseReference.push().setValue(friendlyMessage); } }); } }
From source file:com.oe.phonegap.plugins.AutoRecordVideo.java
/** * Called when the video view exits./*from w w w . j a v a 2s . com*/ * * @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:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activityHelper = ActivityHelper.createInstance(getActivity()); parkingApp = (ParkingApp) getActivity().getApplicationContext(); Intent intent = getSherlockActivity().getIntent(); // TODO Optimize this using savedInstanceState to avoid reload of // identical data onResume if (Intent.ACTION_VIEW.equals(intent.getAction())) { mIdPost = getIdFromUri(intent.getData()); }/*w w w . j a va2 s. c o m*/ // else if ((savedInstanceState != null) // && savedInstanceState.containsKey(Const.KEY_INSTANCE_RINK_ID)) { // mRinkId = savedInstanceState.getInt(Const.KEY_INSTANCE_RINK_ID); // } else { mIdPost = intent.getIntExtra(Const.INTENT_EXTRA_POST_ID, -1); } // mUriPost = Posts.buildPostUri(Integer.toString(mIdPost)); getLoaderManager().initLoader(PostDetailsQuery._TOKEN, null, this); }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
@Override public void onResume() { super.onResume(); mHandler = new NotifyingAsyncQueryHandler(getActivity().getContentResolver(), this); Intent intent = getSherlockActivity().getIntent(); // TODO Optimize this using savedInstanceState to avoid reload of // identical data onResume if (Intent.ACTION_VIEW.equals(intent.getAction())) { mIdPost = getIdFromUri(intent.getData()); }/*from ww w . ja va 2 s .co m*/ // else if ((savedInstanceState != null) // && savedInstanceState.containsKey(Const.KEY_INSTANCE_RINK_ID)) { // mRinkId = savedInstanceState.getInt(Const.KEY_INSTANCE_RINK_ID); // } else { mIdPost = intent.getIntExtra(Const.INTENT_EXTRA_POST_ID, -1); } // mUriPost = Posts.buildPostUri(Integer.toString(mIdPost)); final GregorianCalendar calendar = parkingApp.getParkingCalendar(); final int duration = parkingApp.getParkingDuration(); ((TextView) mView.findViewById(R.id.details_time_title)) .setText(ParkingTimeHelper.getTitle(this.getActivity(), calendar, duration)); }
From source file:com.poinsart.votar.VotarMain.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Bitmap photo = null;//w ww . ja v a2s.c om opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.ARGB_8888; Uri uri = null; if (resultCode != RESULT_OK) return; if (requestCode == GALLERY_REQUEST && data != null && data.getData() != null) { uri = data.getData(); if (uri == null) return; //User had pick an image. Cursor cursor = getContentResolver().query(uri, new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null); cursor.moveToFirst(); //Link to the image lastPhotoFilePath = cursor.getString(0); cursor.close(); } if (requestCode == CAMERA_REQUEST) { uri = cameraFileUri; lastPhotoFilePath = uri.getPath(); } if (lastPhotoFilePath == null) return; lastPointsJsonString = null; new AnalyzeTask().execute(photo); }
From source file:com.aengbee.android.leanback.ui.VideoDetailsFragment.java
/** * Check if there is a global search intent. If there is, load that video. *//*from w w w .j av a2 s . c o m*/ private boolean hasGlobalSearchIntent() { Intent intent = getActivity().getIntent(); String intentAction = intent.getAction(); String globalSearch = getString(R.string.global_search); if (globalSearch.equalsIgnoreCase(intentAction)) { Uri intentData = intent.getData(); String videoId = intentData.getLastPathSegment(); Bundle args = new Bundle(); args.putString(VideoContract.VideoEntry._ID, videoId); getLoaderManager().initLoader(mGlobalSearchVideoId++, args, this); return true; } return false; }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { Log.v(TAG, "onActivityResult: requestCode = " + requestCode + ", resultCode = " + resultCode + ", intent = " + intent);/* w w w .j a v a2s .co m*/ // The user chose a DB file to import. if (requestCode == ACTIVITY_REQUEST_CODE_IMPORT && resultCode == Activity.RESULT_OK) { if (intent == null || intent.getData() == null) { Snackbar.make(mBinding.getRoot(), R.string.import_result_no_file, Snackbar.LENGTH_SHORT).show(); return; } final String filePath = intent.getData().getPath(); if (TextUtils.isEmpty(filePath)) { Snackbar.make(mBinding.getRoot(), R.string.import_result_no_file, Snackbar.LENGTH_SHORT).show(); return; } // Save the uri of the file. We will import it in onResumeFragments. getIntent().putExtra(EXTRA_IMPORT_URI, intent.getData()); } else { super.onActivityResult(requestCode, resultCode, intent); } }
From source file:li.barter.fragments.EditProfileFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) { return;//from www . ja v a2 s.com } switch (requestCode) { case PICK_FROM_CAMERA: // doCrop(PICK_FROM_CAMERA); setAndSaveImage(mCameraImageCaptureUri, PICK_FROM_CAMERA); break; case PICK_FROM_FILE: mGalleryImageCaptureUri = data.getData(); setAndSaveImage(mGalleryImageCaptureUri, PICK_FROM_FILE); // doCrop(PICK_FROM_FILE); break; case CROP_FROM_CAMERA: final Bundle extras = data.getExtras(); if (extras != null) { mCompressedPhoto = extras.getParcelable("data"); mProfileImageView.setImageBitmap(mCompressedPhoto); } PhotoUtils.saveImage(mCompressedPhoto, "barterli_avatar_small.png"); break; case AppConstants.RequestCodes.EDIT_PREFERRED_LOCATION: { loadPreferredLocation(); break; } } }
From source file:com.barcamppenang2014.tabfragment.ProfileFragment.java
License:asdf
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data); Log.d("yc", "call onActivityResult in profilefragment "); if (requestCode == GALLERY_REQUEST_CODE && resultCode == Activity.RESULT_OK) { // Recyle unused bitmaps /*/* ww w .j a v a 2s. co m*/ * if (bitmap != null) { bitmap.recycle(); } */ Uri uri = data.getData(); uriStr = uri.toString(); // save picUri to sharedpreference SharedPreferences sharedpreferences = getActivity().getSharedPreferences("MyPREFERENCES", Context.MODE_PRIVATE); Editor editor = sharedpreferences.edit(); // picUri could be 'none' or a valid picUri editor.putString("picuri", uriStr); editor.commit(); try { URIToBitmap(uri); } catch (Exception e) { e.printStackTrace(); } MainActivity._tempFragment = null; } }