List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:Main.java
public static String getFileFromStorage(Context context, Intent data) { Uri pickedImage = data.getData(); String[] filePath = { MediaStore.Images.Media.DATA }; String path = ""; Cursor cursor = context.getContentResolver().query(pickedImage, filePath, null, null, null); if (cursor != null) { cursor.moveToFirst();/*from www .j a va2 s .c o m*/ path = cursor.getString(cursor.getColumnIndex(filePath[0])); cursor.close(); } return path; }
From source file:Main.java
public static String getFSMSessionFromFSMIntent(Intent intent) { Uri fsmURI = intent.getData(); return getFSMSessionFromUri(fsmURI); }
From source file:Main.java
/** * Retrieve the account UUID, or null if the UUID param is not found. *//*from w ww . j a v a2s .c o m*/ public static String getAccountUuidFromIntent(Intent intent) { final Uri uri = intent.getData(); if (uri == null) { return null; } String uuid = uri.getQueryParameter(ACCOUNT_UUID_PARAM); return TextUtils.isEmpty(uuid) ? null : uuid; }
From source file:Main.java
public static String getVideoPath(Context context, Intent data) { Cursor cursor = context.getContentResolver().query(data.getData(), null, null, null, null); if (cursor != null && cursor.moveToNext()) { String filePath = cursor.getString(cursor.getColumnIndex(VideoColumns.DATA)); return filePath; } else if (data != null && data.getData() != null) { return data.getData().getEncodedPath(); }//from w ww . j a v a2 s . c o m return null; }
From source file:Main.java
/** * Extracts the {@link Uri url} out of an attachment upload. The url is part of the result {@link Intent} in {@link Activity#onActivityResult()} of a former * {@link #startAttachmentActivity()} call. * /*from www . j a v a 2 s .c o m*/ * @param activityResultIntent * Result {@link Intent} from {@link Activity#onActivityResult(int, int, Intent)}. * @return the upload url as {@link Uri} or null, if the result {@link Intent} contains no url. */ public static Uri getUrlFromResult(Intent activityResultIntent) { Uri url = activityResultIntent.getData(); if (url == null) { if (activityResultIntent.hasExtra(EXTRAS_URL)) { url = Uri.parse(activityResultIntent.getStringExtra(EXTRAS_URL)); } } return url; }
From source file:Main.java
public static File parseFileByIntentData(Context context, Intent data) { File file = null;/*from w w w . j a v a 2 s . co m*/ if (data != null && data.getData() != null) { String[] proj = { MediaStore.Images.Media.DATA }; CursorLoader cursorLoader = new CursorLoader(context, data.getData(), proj, null, null, null); Cursor cursor = null; try { cursor = cursorLoader.loadInBackground(); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); file = new File(cursor.getString(column_index)); } catch (Exception e) { e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } } return file; }
From source file:Main.java
private static long getLongFromIntent(Intent intent, String paramName) { long value = -1; if (intent.getData() != null) { value = getLongParamFromUri(intent.getData(), paramName, -1); }//from w w w . j av a2 s .c om return value; }
From source file:com.achep.acdisplay.receiver.LocalReceiverActivity.java
static String extractHost(Intent intent) { Uri data = intent.getData(); return data != null ? data.getHost() : null; }
From source file:Main.java
public static void dumpIntent(Intent intent) { System.out.println("action: " + intent.getAction()); System.out.println("data: " + intent.getData()); System.out.println("extras:"); Bundle bundle = intent.getExtras();//from ww w . j av a 2 s.c o m for (String key : bundle.keySet()) { Object object = bundle.get(key); System.out.println(key + "->" + object + "(" + object.getClass().getName() + ")"); } }
From source file:Main.java
/** * Returns a bitmap from a gallery Uri/*from w w w . j a v a2 s. c o m*/ * * @param pContext * Context required to access the content resolver * @param pIntent * The Uri of the picker image * @return The picked image as a bitmap */ public static Bitmap getBitmapFromIntent(Context pContext, Intent pIntent) { Bitmap bitmapPickedImage = null; Uri pickedImageUri = pIntent.getData(); // If the URI is not null try to decode it to a bitmap else try to get the bitmap data from the intent // http://stackoverflow.com/questions/17123083/null-pointer-exception-while-taking-pictures-from-camera-android-htc if (pickedImageUri != null) { try { InputStream imageStream = pContext.getContentResolver().openInputStream(pickedImageUri); bitmapPickedImage = BitmapFactory.decodeStream(imageStream); } catch (FileNotFoundException e) { e.printStackTrace(); } } else { if (pIntent.getExtras() != null && pIntent.getExtras().get("data") instanceof Bitmap) { bitmapPickedImage = (Bitmap) pIntent.getExtras().get("data"); } } return bitmapPickedImage; }