List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:edu.mit.mobile.android.locast.sync.MediaSync.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (ACTION_SYNC_RESOURCES.equals(intent.getAction())) { final Uri data = intent.getData(); if (data == null) { enqueueUnpublishedMedia();/* w ww . j a v a 2s . c o m*/ } else { enqueueItem(data, intent.getExtras()); } } else { Log.e(TAG, "Media Sync was told to start with an unhandled intent: " + intent); } return START_REDELIVER_INTENT; }
From source file:mobisocial.socialkit.musubi.Musubi.java
public DbObj objFromIntent(Intent intent) { Log.d(TAG, "fetching obj from " + intent); if (intent.hasExtra(EXTRA_OBJ_URI)) { try {// w w w.jav a2 s .co m Uri objUri = intent.getParcelableExtra(EXTRA_OBJ_URI); return objForUri(objUri); } catch (Exception e) { if (DBG) Log.e(TAG, "couldnt get obj from uri", e); } } if (intent.getType() != null && intent.getType().startsWith("vnd.musubi.obj/")) { if (intent.getData() != null) { return objForUri(intent.getData()); } } if (DBG) Log.e(TAG, "no obj found"); return null; }
From source file:de.stadtrallye.rallyesoft.model.pictures.PictureManager.java
public Picture onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(THIS, "Received ActivityResult: Req: " + requestCode + ", res: " + resultCode + ", Intent: " + data); if (resultCode == Activity.RESULT_OK) { if (unconfirmed == null) { Log.e(THIS, "No picture requested"); throw new UnsupportedOperationException("uncomfirmed == null, should not have happened"); }/*w w w . j a v a 2s .co m*/ Uri uri = null; //It can either be returned with the intent parameter: if (data != null) { uri = data.getData(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { takePersistableUriPermissionApi19(data, uri); } pickedPicture(uri); } else {//else we use the saved value tookPicture(); } return unconfirmed; } else { Log.v(THIS, "Negative result code"); return null; } }
From source file:com.grass.caishi.cc.activity.RegisterActivity.java
/** * onActivityResult/* w w w . j a va 2s . c o m*/ */ public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == USERPIC_REQUEST_CODE_CAMERA) { // ? if (cameraFile != null && cameraFile.exists()) { // Log.d("cameraFile"+cameraFile.getAbsolutePath()); // ?uri imageUri = Uri.fromFile(cameraFile); cropImageUri(Uri.fromFile(cameraFile), 300, 300, USERPIC_REQUEST_CODE_CUT); } } else if (requestCode == USERPIC_REQUEST_CODE_LOCAL) { // ? if (data != null) { Uri selectedImage = data.getData(); if (selectedImage != null) { cropImageUri(selectedImage, 300, 300, USERPIC_REQUEST_CODE_CUT); // Log.d("log","selectedImage"+selectedImage); } } } else if (requestCode == USERPIC_REQUEST_CODE_CUT) {// ? // ? if (data != null) { Bitmap bitmap = data.getParcelableExtra("data"); if (bitmap == null) { Toast.makeText(RegisterActivity.this, "??", Toast.LENGTH_SHORT).show(); } else { user_logo.setBackgroundColor(Color.parseColor("#00000000")); user_logo.setImageBitmap(bitmap); lastFile = saveJPGE_After(bitmap, cameraFile); // ???? } } else { // Log.e(TAG, "CHOOSE_SMALL_PICTURE: data = " + data); } } }
From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == SELECT_FILE) { Bitmap photo;/* w w w. jav a2 s. c om*/ try { photo = (Bitmap) MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData()); Uri tempUri = getImageUri(getApplicationContext(), photo); imageUrls = (getRealPathFromURI(tempUri)); tv_pic.setText(imageUrls); } catch (IOException e) { e.printStackTrace(); } // onSelectFromGalleryResult(data); } else if (requestCode == REQUEST_CAMERA) { // onCaptureImageResult(data); Bitmap photo; photo = (Bitmap) data.getExtras().get("data"); Uri tempUri = getImageUri(getApplicationContext(), photo); imageUrls = (getRealPathFromURI(tempUri)); } } /*if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { Bitmap photo = (Bitmap) data.getExtras().get("data"); //imageView.setImageBitmap(photo); //knop.setVisibility(Button.VISIBLE); // CALL THIS METHOD TO GET THE URI FROM THE BITMAP Uri tempUri = getImageUri(getApplicationContext(), photo); m1 = getRealPathFromURI(tempUri); mStore.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ok_filled,0); // CALL THIS METHOD TO GET THE ACTUAL PATH //file1 = new File(getRealPathFromURI(tempUri)); //System.out.println(mImageCaptureUri); } else if (requestCode == CAMERA_REQUEST1 && resultCode == RESULT_OK) { Bitmap photo = (Bitmap) data.getExtras().get("data"); //imageView.setImageBitmap(photo); //knop.setVisibility(Button.VISIBLE); // CALL THIS METHOD TO GET THE URI FROM THE BITMAP Uri tempUri = getImageUri(getApplicationContext(), photo); m2 = getRealPathFromURI(tempUri); mDoc.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ok_filled,0); // CALL THIS METHOD TO GET THE ACTUAL PATH // file2 = new File(getRealPathFromURI(tempUri)); //System.out.println(mImageCaptureUri); }*/ }
From source file:nf.frex.android.FrexActivity.java
private boolean tryReadingFrexDocIntent(Intent intent) { if (intent != null) { Uri data = intent.getData(); if (data != null) { try { readFrexDoc(data);// w w w .j av a 2 s. c o m return true; } finally { intent.setData(null); } } } return false; }
From source file:com.snappy.CameraCropActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch (requestCode) { case GALLERY: try { Uri selected_image = data.getData(); //String selected_image_path = getImagePath(selected_image); String selected_image_path = FileUtils.getPath(this, selected_image); onPhotoTaken(selected_image_path); } catch (Exception e) { Toast.makeText(this, R.string.cameracrop_imageload_failed, Toast.LENGTH_LONG).show(); e.printStackTrace();/*from www .ja va 2 s .c o m*/ finish(); } break; case CAMERA: File file = new File(_path); boolean exists = file.exists(); if (exists) onPhotoTaken(_path); else Toast.makeText(getBaseContext(), R.string.cameracrop_image_fatalerror, Toast.LENGTH_SHORT) .show(); break; default: finish(); break; } } /** if there is no image, just finish the activity */ else { finish(); } }
From source file:com.ximai.savingsmore.save.activity.BusinessMyCenterActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (resultCode != RESULT_OK) { return;// w w w . ja va2s .c o m } else if (requestCode == PICK_FROM_CAMERA || requestCode == PICK_FROM_IMAGE) { Uri uri = null; if (null != intent && intent.getData() != null) { uri = intent.getData(); } else { String fileName = PreferencesUtils.getString(this, "tempName"); uri = Uri.fromFile(new File(FileSystem.getCachesDir(this, true).getAbsolutePath(), fileName)); } if (uri != null) { cropImage(uri, CROP_PHOTO_CODE); } } else if (requestCode == CROP_PHOTO_CODE) { Uri photoUri = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT); if (isslinece) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), slience_image); zhizhao_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "BusinessLicense"); } catch (URISyntaxException e) { e.printStackTrace(); } } else if (isZhengshu) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), zhengshu_iamge); xukezheng_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "LicenseKey"); } catch (URISyntaxException e) { e.printStackTrace(); } } else if (isheadImage) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), head_image); tuoxiang_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "Photo"); } catch (URISyntaxException e) { e.printStackTrace(); } //upLoadImage(new File((new URI(photoUri.toString()))), "Photo"); } else if (isItem) { if (imagePath.size() + images.size() < 10) { shangpu_path.add(photoUri.toString()); try { upLoadImage(new File((new URI(photoUri.toString()))), "Seller"); } catch (URISyntaxException e) { e.printStackTrace(); } //imagePath.add(photoUri.getPath()); } else { Toast.makeText(BusinessMyCenterActivity.this, "?9", Toast.LENGTH_SHORT).show(); } } //addImage(imagePath); } }
From source file:com.sxt.superqq.activity.RegisterActivity.java
/** * ?Activity// www .j a v a 2s. c o m */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) { return; } String userName = getUserName(); switch (requestCode) { case OnSetAvatarClickListener.REQUEST_TAKE_PHOTO: if (!TextUtils.isEmpty(userName)) { Uri uri = Uri.fromFile(mOnSetAvatarListener.getAvatarFile(RegisterActivity.this, userName)); //??Activity mOnSetAvatarListener.startCropPhoto(uri, 200, 200, OnSetAvatarClickListener.REQUEST_CROP_PHOTO, true); } break; case OnSetAvatarClickListener.REQEUST_CHOOS_PHOTO: //??Activity mOnSetAvatarListener.startCropPhoto(data.getData(), 200, 200, OnSetAvatarClickListener.REQUEST_CROP_PHOTO, true); break; case OnSetAvatarClickListener.REQUEST_CROP_PHOTO://??Activity mOnSetAvatarListener.closePopuAvatar(); //ImageView?sd? mOnSetAvatarListener.saveCropPhoto(mivAvatar, data, userName); break; } }
From source file:com.wiret.arbrowser.AbstractArchitectCamActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == KmlFileBrowserActivity.FILE_SELECT_CODE) { if (resultCode == RESULT_OK) { try { String filename = ""; Uri uri = data.getData(); if (false) { Toast.makeText(this, "The selected file is too large. Selet a new file with size less than 2mb", Toast.LENGTH_LONG).show(); } else { String mimeType = getContentResolver().getType(uri); if (mimeType == null) { String path = getPath(this, uri); if (path == null) { filename = FilenameUtils.getName(uri.toString()); } else { File file = new File(path); filename = file.getName(); }//from www . ja v a 2 s. c o m } else { Uri returnUri = data.getData(); Cursor returnCursor = getContentResolver().query(returnUri, null, null, null, null); int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE); returnCursor.moveToFirst(); filename = returnCursor.getString(nameIndex); String size = Long.toString(returnCursor.getLong(sizeIndex)); } String sourcePath = getExternalFilesDir(null).toString(); try { File outputPath = new File(sourcePath + "/" + filename); copyFileStream(outputPath, uri, this); importData(outputPath.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } } }