List of usage examples for android.net Uri getPath
@Nullable public abstract String getPath();
From source file:com.mobicage.rogerthat.GroupDetailActivity.java
private Bitmap squeezeImage(Uri source) { T.UI();//from ww w. ja v a2 s . c om Bitmap bm = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(source.getPath()), AVATAR_SIZE, AVATAR_SIZE, false); try { FileOutputStream out = new FileOutputStream(mUriSavedImage.getPath()); try { bm.compress(Bitmap.CompressFormat.PNG, 100, out); } finally { out.close(); } } catch (Exception e1) { L.bug(e1); return null; } mPhoneExifRotation = CropUtil.getExifRotation(source.getPath()); return ImageHelper.rotateBitmap(bm, mPhoneExifRotation); }
From source file:com.openerp.base.ir.Attachment.java
@SuppressWarnings("deprecation") private Notification setFileIntent(Uri uri) { Log.v(TAG, "setFileIntent()"); Intent intent = new Intent(Intent.ACTION_VIEW); FileNameMap mime = URLConnection.getFileNameMap(); String mimeType = mime.getContentTypeFor(uri.getPath()); intent.setDataAndType(uri, mimeType); mNotificationResultIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationBuilder.addAction(R.drawable.ic_oe_notification, "Download attachment", mNotificationResultIntent);// ww w. j av a 2 s .c o m mNotificationBuilder.setOngoing(false); mNotificationBuilder.setAutoCancel(true); mNotificationBuilder.setContentTitle("Attachment downloaded"); mNotificationBuilder.setContentText("Download Complete"); mNotificationBuilder.setProgress(0, 0, false); mNotification = mNotificationBuilder.build(); mNotification.setLatestEventInfo(mContext, "Attachment downloaded", "Download complete", mNotificationResultIntent); return mNotification; }
From source file:com.getchute.android.photopickerplus.ui.activity.ServicesActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK && resultCode != AuthenticationActivity.RESULT_DIFFERENT_CHUTE_USER_AUTHENTICATED) { return;//from ww w .j a v a 2 s. co m } 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(new AccountsCallback()); request.setAuthenticationProvider(new CustomAuthenticationProvider(newSessionToken)); request.executeAsync(); } } else { GCAccounts.allUserAccounts(new AccountsCallback()).executeAsync(); } return; } if (requestCode == PhotosIntentWrapper.ACTIVITY_FOR_RESULT_STREAM_KEY) { finish(); return; } if (requestCode == Constants.CAMERA_PIC_REQUEST) { startMediaScanner(photoFile.getAbsolutePath(), MediaType.IMAGE, data); } if (requestCode == Constants.CAMERA_VIDEO_REQUEST) { String path = ""; Uri uriVideo = null; if (data != null) { uriVideo = data.getData(); } path = (uriVideo != null) ? uriVideo.getPath() : AppUtil.getOutputMediaFileUri(MediaType.VIDEO).getPath(); startMediaScanner(path, MediaType.VIDEO, data); } }
From source file:com.app.uafeed.fragment.EntryFragment.java
public void setData(Uri uri) { mCurrentPagerPos = -1;/*from ww w . j av a 2s .com*/ mBaseUri = FeedData.EntryColumns.PARENT_URI(uri.getPath()); try { mInitialEntryId = Long.parseLong(uri.getLastPathSegment()); } catch (Exception unused) { mInitialEntryId = -1; } if (mBaseUri != null) { Bundle b = getActivity().getIntent().getExtras(); String whereClause = FeedData.shouldShowReadEntries(mBaseUri) || (b != null && b.getBoolean(Constants.INTENT_FROM_WIDGET, false)) ? null : EntryColumns.WHERE_UNREAD; // Load the entriesIds list. Should be in a loader... but I was too lazy to do so Cursor entriesCursor = MainApplication.getContext().getContentResolver().query(mBaseUri, EntryColumns.PROJECTION_ID, whereClause, null, EntryColumns.DATE + Constants.DB_DESC); if (entriesCursor != null && entriesCursor.getCount() > 0) { mEntriesIds = new long[entriesCursor.getCount()]; int i = 0; while (entriesCursor.moveToNext()) { mEntriesIds[i] = entriesCursor.getLong(0); if (mEntriesIds[i] == mInitialEntryId) { mCurrentPagerPos = i; // To immediately display the good entry } i++; } entriesCursor.close(); } } else { mEntriesIds = null; } mEntryPagerAdapter.notifyDataSetChanged(); if (mCurrentPagerPos != -1) { mEntryPager.setCurrentItem(mCurrentPagerPos); } }
From source file:com.polyvi.xface.extension.zip.XZipExt.java
/** * /*w w w. ja va 2 s. co m*/ * * @param srcFileUri * @param zos * @param entry * @throws IOException * @throws IllegalArgumentException */ private void compressDir(Uri srcFileUri, ZipOutputStream zos, String entry) throws IOException, IllegalArgumentException { if (null == zos) { XLog.e(CLASS_NAME, "Method compressDir: param is null!"); throw new IllegalArgumentException(); } if (srcFileUri.getPath().startsWith(XConstant.ANDROID_ASSET)) { compressAssetsFile(srcFileUri, zos, entry); } else { compressNormalFile(srcFileUri, zos, entry); } }
From source file:com.benefit.buy.library.http.query.callback.AbstractAjaxCallback.java
private static String extractUrl(Uri uri) { String result = uri.getScheme() + "://" + uri.getAuthority() + uri.getPath(); String fragment = uri.getFragment(); if (fragment != null) { result += "#" + fragment; }/*from w ww. j ava 2s. co m*/ return result; }
From source file:net.sf.asap.Player.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Uri uri = getIntent().getData(); filename = uri.getLastPathSegment(); ZipFile zip = null;/*from w ww . j a va2 s .com*/ final byte[] module = new byte[ASAPInfo.MAX_MODULE_LENGTH]; int moduleLen; try { InputStream is; if (Util.isZip(filename)) { zip = new ZipFile(uri.getPath()); filename = uri.getFragment(); is = zip.getInputStream(zip.getEntry(filename)); } else { try { is = getContentResolver().openInputStream(uri); } catch (FileNotFoundException ex) { if (uri.getScheme().equals("http")) is = httpGet(uri); else throw ex; } } moduleLen = readAndClose(is, module); } catch (IOException ex) { showError(R.string.error_reading_file); return; } finally { Util.close(zip); } try { asap.load(filename, module, moduleLen); } catch (Exception ex) { showError(R.string.invalid_file); return; } info = asap.getInfo(); setTitle(R.string.playing_title); setContentView(R.layout.playing); setTag(R.id.name, info.getTitleOrFilename()); setTag(R.id.author, info.getAuthor()); setTag(R.id.date, info.getDate()); findViewById(R.id.stop_button).setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); mediaController = new MediaController(this, false); mediaController.setAnchorView(getContentView()); mediaController.setMediaPlayer(new MediaController.MediaPlayerControl() { public boolean canPause() { return !isPaused(); } public boolean canSeekBackward() { return false; } public boolean canSeekForward() { return false; } public int getBufferPercentage() { return 100; } public int getCurrentPosition() { return asap.getPosition(); } public int getDuration() { return info.getDuration(song); } public boolean isPlaying() { return !isPaused(); } public void pause() { audioTrack.pause(); } public void seekTo(int pos) { seek(pos); } public void start() { resume(); } }); if (info.getSongs() > 1) { mediaController.setPrevNextListeners(new OnClickListener() { public void onClick(View v) { playNextSong(); } }, new OnClickListener() { public void onClick(View v) { playPreviousSong(); } }); } new Handler().postDelayed(new Runnable() { public void run() { mediaController.show(); } }, 500); stop = false; playSong(info.getDefaultSong()); new Thread(this).start(); }
From source file:com.mappn.gfan.ui.HomeTabActivity.java
private boolean checkDownload() { Cursor cursor = mSession.getDownloadManager() .query(new DownloadManager.Query().setFilterById(mSession.getUpdateId())); if (cursor != null && cursor.moveToFirst()) { int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.Impl.COLUMN_STATUS)); if (DownloadManager.Impl.STATUS_SUCCESS == status) { String fileSrc = cursor.getString(cursor.getColumnIndex(DownloadManager.Impl.COLUMN_DATA)); Uri uri = Uri.parse(fileSrc); File file = new File(uri.getPath()); if (!file.exists()) { return false; }//from ww w. ja v a 2 s . c om File root = new File(Environment.getExternalStorageDirectory(), com.mappn.gfan.Constants.IMAGE_CACHE_DIR); root.mkdirs(); File output = new File(root, "aMarket.apk"); if (!output.exists()) { try { Utils.copyFile(new FileInputStream(file), new FileOutputStream(output)); } catch (FileNotFoundException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } } Utils.installApk(getApplicationContext(), output); return true; } } return false; }
From source file:com.jecelyin.editor.v2.ui.MainActivity.java
private boolean processIntentImpl() throws Throwable { Intent intent = getIntent();//from w w w. j ava2s . c o m L.d("intent=" + intent); if (intent == null) return true; //pass hint String action = intent.getAction(); // action == null if change theme if (action == null || Intent.ACTION_MAIN.equals(action)) { return true; } if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action)) { if (intent.getScheme().equals("content")) { InputStream attachment = getContentResolver().openInputStream(intent.getData()); String text = IOUtils.toString(attachment); openText(text); return true; } else if (intent.getScheme().equals("file")) { Uri mUri = intent.getData(); String file = mUri != null ? mUri.getPath() : null; if (!TextUtils.isEmpty(file)) { openFile(file); return true; } } } else if (Intent.ACTION_SEND.equals(action) && intent.getExtras() != null) { Bundle extras = intent.getExtras(); CharSequence text = extras.getCharSequence(Intent.EXTRA_TEXT); if (text != null) { openText(text); return true; } else { Object stream = extras.get(Intent.EXTRA_STREAM); if (stream != null && stream instanceof Uri) { openFile(((Uri) stream).getPath()); return true; } } } return false; }