List of usage examples for android.net Uri getPath
@Nullable public abstract String getPath();
From source file:com.kanedias.vanilla.lyrics.LyricsShowActivity.java
/** * Write lyrics as a *.lrc file - selects SAF/File routine based on target access. * Resulting file should be placed in the same directory as media file but with *.lrc extension instead. *///from w w w . j ava2 s. c o m private void persistAsLrcFile() { Uri fileUri = getIntent().getParcelableExtra(EXTRA_PARAM_URI); if (fileUri == null || fileUri.getPath() == null) { // wrong intent passed? return; } File mediaFile = new File(fileUri.getPath()); if (!mediaFile.exists()) { // file deleted while launching intent or player db is not refreshed return; } String lrcFilename = lyricsForFile(mediaFile); File lrcTarget = new File(mediaFile.getParent(), lrcFilename); byte[] data = mLyricsText.getText().toString().getBytes(Charset.forName("UTF-8")); if (isSafNeeded(mediaFile, this)) { if (mPrefs.contains(PREF_SDCARD_URI)) { // we already got the permission! writeThroughSaf(data, mediaFile, lrcTarget.getName()); return; } // request SAF permissions in handler mSafHandler.handleFile(mediaFile); } else { writeThroughFile(data, lrcTarget); } }
From source file:com.handpoint.headstart.client.ui.ReceiptActivity.java
ArrayList<File> getMerchantEmailAttachments() { ArrayList<File> attachments = new ArrayList<File>(); boolean isSignature = false; //get signature if any if (null != mResult && null != mResult.getSignaturePath()) { String path = getFilePathFromContentUrl(mResult.getSignaturePath()); Uri uri = Uri.parse(path); File signature = new File(uri.getPath()); attachments.add(signature);/*w w w . j a va 2s . c o m*/ isSignature = true; } //get receipt if exists File receipt = getMerchantEmailAttachmentFile(isSignature); if (null != receipt) attachments.add(receipt); return attachments; }
From source file:com.gsma.rcs.provisioning.local.Provisioning.java
private void loadProfile(ContactId contact, Uri provisioningFile) { final boolean logActivated = sLogger.isActivated(); try {/*www . j a v a 2 s . c o m*/ if (logActivated) { sLogger.debug("Selection of provisioning file: ".concat(provisioningFile.getPath())); } String xMLFileContent = getFileContent(provisioningFile); LoadXmlPovisioningTask mProvisionTask = new LoadXmlPovisioningTask(); mProvisionTask.execute(xMLFileContent, contact.toString()); } catch (IOException e) { if (logActivated) { sLogger.debug("Loading of provisioning failed: invalid XML file '" + provisioningFile + "', Message=" + e.getMessage()); } Toast.makeText(mActivity, getString(R.string.label_load_failed), Toast.LENGTH_LONG).show(); } }
From source file:com.polyvi.xface.extension.zip.XZipExt.java
/** * assets// w w w .j av a 2 s .com * * @param srcFileUri * @param zos * @param entry * @throws IOException */ private void compressAssetsFile(Uri srcFileUri, ZipOutputStream zos, String entry) throws IOException, FileNotFoundException { srcFileUri = handleUri(srcFileUri); String srcPath = srcFileUri.getPath().substring(XConstant.ANDROID_ASSET.length()); if (XAssetsFileUtils.isFile(mContext, srcPath)) { zipFile(srcFileUri, zos, entry + srcFileUri.getLastPathSegment()); } else { String childrens[] = mContext.getAssets().list(srcPath); if (null == childrens || 0 == childrens.length) { XLog.e(CLASS_NAME, "Method compressAssetsFile: Source file path does not exist!"); throw new FileNotFoundException(); } Uri srcRootUri = srcFileUri; for (int index = 0; index < childrens.length; index++) { srcFileUri = Uri.parse(srcRootUri.toString() + File.separator + childrens[index]); if (XAssetsFileUtils.isFile(mContext, srcPath + File.separator + childrens[index])) { zipFile(srcFileUri, zos, entry + childrens[index]); } else { compressAssetsFile(srcFileUri, zos, entry + childrens[index] + File.separator); } } } }
From source file:com.handpoint.headstart.client.ui.ReceiptActivity.java
ArrayList<File> getCustomerEmailAttachments() { ArrayList<File> attachments = new ArrayList<File>(); //get receipt if exists File receipt = getCustomerEmailAttachmentFile(); if (null != receipt) attachments.add(receipt);/*from w ww . ja v a 2 s . c o m*/ //get image if exists if (null != mBasketItem && null != mBasketItem.getFullSizePhotoPath()) { Uri uri = Uri.parse(mBasketItem.getFullSizePhotoPath()); File photo = new File(uri.getPath()); attachments.add(photo); } return attachments; }
From source file:com.chute.android.photopickerplus.ui.activity.ServicesActivity.java
@SuppressLint("NewApi") @Override//from w w w . j av a2s.c om protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK && resultCode != AuthenticationActivity.RESULT_DIFFERENT_CHUTE_USER_AUTHENTICATED) { return; } if (requestCode == AuthenticationFactory.AUTHENTICATION_REQUEST_CODE) { if (data != null) { String newSessionToken = data.getExtras() .getString(AuthenticationActivity.INTENT_DIFFERENT_CHUTE_USER_TOKEN); String previousSessionToken = TokenAuthenticationProvider.getInstance().getToken(); if (!newSessionToken.equals(previousSessionToken)) { CurrentUserAccountsRequest request = new CurrentUserAccountsRequest(getApplicationContext(), new AccountsCallback()); request.getClient().setAuthentication(new CustomAuthenticationProvider(newSessionToken)); request.executeAsync(); } } else { GCAccounts.allUserAccounts(getApplicationContext(), new AccountsCallback()).executeAsync(); } return; } if (requestCode == PhotosIntentWrapper.ACTIVITY_FOR_RESULT_STREAM_KEY) { finish(); return; } if (requestCode == Constants.CAMERA_PIC_REQUEST) { String path = ""; File tempFile = AppUtil.getTempImageFile(getApplicationContext()); if (AppUtil.hasImageCaptureBug() == false && tempFile.length() > 0) { try { android.provider.MediaStore.Images.Media.insertImage(getContentResolver(), tempFile.getAbsolutePath(), null, null); tempFile.delete(); path = MediaDAO.getLastPhotoFromCameraPhotos(getApplicationContext()).toString(); } catch (FileNotFoundException e) { ALog.d("", e); } } else { ALog.e("Bug " + data.getData().getPath()); path = Uri.fromFile(new File(AppUtil.getPath(getApplicationContext(), data.getData()))).toString(); } final AssetModel model = new AssetModel(); model.setThumbnail(path); model.setUrl(path); model.setType(MediaType.IMAGE.name().toLowerCase()); ArrayList<AssetModel> mediaCollection = new ArrayList<AssetModel>(); mediaCollection.add(model); setResult(Activity.RESULT_OK, new Intent().putExtra(PhotosIntentWrapper.KEY_PHOTO_COLLECTION, mediaCollection)); finish(); } if (requestCode == Constants.CAMERA_VIDEO_REQUEST) { Uri uriVideo = data.getData(); File file = new File(uriVideo.getPath()); Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(file.getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND); final AssetModel model = new AssetModel(); model.setThumbnail(AppUtil.getImagePath(getApplicationContext(), thumbnail)); model.setVideoUrl(uriVideo.toString()); model.setUrl(AppUtil.getImagePath(getApplicationContext(), thumbnail)); model.setType(MediaType.VIDEO.name().toLowerCase()); ArrayList<AssetModel> mediaCollection = new ArrayList<AssetModel>(); mediaCollection.add(model); setResult(Activity.RESULT_OK, new Intent().putExtra(PhotosIntentWrapper.KEY_PHOTO_COLLECTION, mediaCollection)); finish(); } }
From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java
/** * Start the camera by dispatching a camera intent. *//*ww w . j av a2s. co m*/ protected void dispatchTakePictureIntent(boolean isFinishingService) { // Check if there is a camera. Context context = getActivity(); PackageManager packageManager = context.getPackageManager(); if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA) == false) { Toast.makeText(getActivity(), "This device does not have a camera.", Toast.LENGTH_SHORT).show(); return; } // Camera exists? Then proceed... Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent DetalleServicioActivity activity = (DetalleServicioActivity) getActivity(); if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) { // Create the File where the photo should go. // If you don't do this, you may get a crash in some devices. File photoFile = null; try { photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File Toast toast = Toast.makeText(activity, "There was a problem saving the photo...", Toast.LENGTH_SHORT); toast.show(); } // Continue only if the File was successfully created if (photoFile != null) { Uri fileUri = Uri.fromFile(photoFile); activity.setCapturedImageURI(fileUri); activity.setCurrentPhotoPath(fileUri.getPath()); activity.setIsFinishingService(isFinishingService); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, activity.getCapturedImageURI()); startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO); } } }
From source file:com.openerp.base.ir.Attachment.java
private void requestIntent(Uri uri) { Intent intent = new Intent(Intent.ACTION_VIEW); FileNameMap mime = URLConnection.getFileNameMap(); String mimeType = mime.getContentTypeFor(uri.getPath()); intent.setDataAndType(uri, mimeType); mContext.startActivity(intent);//from ww w. j a va 2 s. co m }
From source file:ir.keloud.android.lib.common.KeloudSamlSsoCredentials.java
@Override public void applyTo(KeloudClient client) { client.getParams().setAuthenticationPreemptive(false); client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); client.setFollowRedirects(false);/* ww w. j a v a 2 s.c o m*/ Uri serverUri = client.getBaseUri(); String[] cookies = mSessionCookie.split(";"); if (cookies.length > 0) { Cookie cookie = null; for (int i = 0; i < cookies.length; i++) { int equalPos = cookies[i].indexOf('='); if (equalPos >= 0) { cookie = new Cookie(); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT cookie.setPath(serverUri.getPath()); // VERY IMPORTANT client.getState().addCookie(cookie); } } } }
From source file:com.cerema.cloud2.lib.common.OwnCloudSamlSsoCredentials.java
@Override public void applyTo(OwnCloudClient client) { client.getParams().setAuthenticationPreemptive(false); client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); client.setFollowRedirects(false);/*from w ww . j a v a 2 s . co m*/ Uri serverUri = client.getBaseUri(); String[] cookies = mSessionCookie.split(";"); if (cookies.length > 0) { Cookie cookie = null; for (int i = 0; i < cookies.length; i++) { int equalPos = cookies[i].indexOf('='); if (equalPos >= 0) { cookie = new Cookie(); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT cookie.setPath(serverUri.getPath()); // VERY IMPORTANT client.getState().addCookie(cookie); } } } }