List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:Main.java
public static Uri handleChoosenImage(Intent data, Uri fileUri) { final boolean isCamera; if (data == null) { isCamera = true;/* ww w . j av a 2 s. c o m*/ } else { final String action = data.getAction(); if (action == null) { isCamera = false; } else { isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); } } Uri selectedImageUri; if (isCamera) { selectedImageUri = fileUri; } else { selectedImageUri = data == null ? null : data.getData(); } return selectedImageUri; }
From source file:bolts.MeasurementEvent.java
/** * Broadcast Bolts measurement event.//from w w w. j a v a2 s .com * Bolts raises events to the application with this method by sending * {@link #MEASUREMENT_EVENT_NOTIFICATION_NAME} broadcast. * * @param context the context of activity or application who is going to send the event. required. * @param name the event name that is going to be sent. required. * @param intent the intent that carries the logging data in its extra bundle and data url. optional. * @param extraLoggingData other logging data to be sent in events argument. optional. * */ static void sendBroadcastEvent(Context context, String name, Intent intent, Map<String, String> extraLoggingData) { Bundle logData = new Bundle(); if (intent != null) { Bundle applinkData = AppLinks.getAppLinkData(intent); if (applinkData != null) { logData = getApplinkLogData(context, name, applinkData, intent); } else { Uri intentUri = intent.getData(); if (intentUri != null) { logData.putString("intentData", intentUri.toString()); } Bundle intentExtras = intent.getExtras(); if (intentExtras != null) { for (String key : intentExtras.keySet()) { Object o = intentExtras.get(key); String logValue = objectToJSONString(o); logData.putString(key, logValue); } } } } if (extraLoggingData != null) { for (String key : extraLoggingData.keySet()) { logData.putString(key, extraLoggingData.get(key)); } } MeasurementEvent event = new MeasurementEvent(context, name, logData); event.sendBroadcast(); }
From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static final AddContentRelatedRepresentation prepareTransfer(Intent resultData, AlfrescoFragment fr, String id, int type) { Uri uri = null;//from ww w . jav a2s . com if (resultData != null) { uri = resultData.getData(); Log.i("TAG", "uri: " + uri); // Detect if it comes from Alfresco ? if (AlfrescoIntegrator.STORAGE_ACCESS_PROVIDER.equals(uri.getAuthority())) { // It's alfresco ! // Let's see if it's possible to link... AddContentRelatedRepresentation content = prepareLink(fr, uri); if (content == null) { // Link is impossible we upload the document requestUpload(fr, uri, id, type, resultData.getType()); } else { // Link is possible. // Let's request the user on how to handle this uploadAs(fr, uri, content, id, type, resultData.getType()); } } else { // It's something else requestUpload(fr, uri, id, type, resultData.getType()); } } return null; }
From source file:com.facebook.AppLinkData.java
private static AppLinkData createFromAlApplinkData(Intent intent) { Bundle applinks = intent.getBundleExtra(BUNDLE_AL_APPLINK_DATA_KEY); if (applinks == null) { return null; }/*from ww w.j av a 2 s . c om*/ AppLinkData appLinkData = new AppLinkData(); appLinkData.targetUri = intent.getData(); if (appLinkData.targetUri == null) { String targetUriString = applinks.getString(METHOD_ARGS_TARGET_URL_KEY); if (targetUriString != null) { appLinkData.targetUri = Uri.parse(targetUriString); } } appLinkData.argumentBundle = applinks; appLinkData.arguments = null; Bundle refererData = applinks.getBundle(ARGUMENTS_REFERER_DATA_KEY); if (refererData != null) { appLinkData.ref = refererData.getString(REFERER_DATA_REF_KEY); } return appLinkData; }
From source file:bolts.MeasurementEvent.java
private static Bundle getApplinkLogData(Context context, String eventName, Bundle appLinkData, Intent applinkIntent) { Bundle logData = new Bundle(); ComponentName resolvedActivity = applinkIntent.resolveActivity(context.getPackageManager()); if (resolvedActivity != null) { logData.putString("class", resolvedActivity.getShortClassName()); }/* www. ja v a2s. co m*/ if (APP_LINK_NAVIGATE_OUT_EVENT_NAME.equals(eventName)) { if (resolvedActivity != null) { logData.putString("package", resolvedActivity.getPackageName()); } if (applinkIntent.getData() != null) { logData.putString("outputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("outputURLScheme", applinkIntent.getScheme()); } } else if (APP_LINK_NAVIGATE_IN_EVENT_NAME.equals(eventName)) { if (applinkIntent.getData() != null) { logData.putString("inputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("inputURLScheme", applinkIntent.getScheme()); } } for (String key : appLinkData.keySet()) { Object o = appLinkData.get(key); if (o instanceof Bundle) { for (String subKey : ((Bundle) o).keySet()) { String logValue = objectToJSONString(((Bundle) o).get(subKey)); if (key.equals("referer_app_link")) { if (subKey.equalsIgnoreCase("url")) { logData.putString("refererURL", logValue); continue; } else if (subKey.equalsIgnoreCase("app_name")) { logData.putString("refererAppName", logValue); continue; } else if (subKey.equalsIgnoreCase("package")) { logData.putString("sourceApplication", logValue); continue; } } logData.putString(key + "/" + subKey, logValue); } } else { String logValue = objectToJSONString(o); if (key.equals("target_url")) { Uri targetURI = Uri.parse(logValue); logData.putString("targetURL", targetURI.toString()); logData.putString("targetURLHost", targetURI.getHost()); continue; } logData.putString(key, logValue); } } return logData; }
From source file:com.albedinsky.android.support.intent.ImageIntent.java
/** * Processes the given result <var>data</var> intent to obtain a user's picked image. * <p>//www.ja va2 s. co m * <b>Note</b>, that in case of {@link #REQUEST_CODE_CAMERA}, the captured photo's bitmap will be * received only in quality of "place holder" image, not as full quality image. For full quality * photo pass an instance of Uri to {@link #output(Uri)} and the bitmap of the captured * photo will be stored on the specified uri. * * @param requestCode The request code from {@link Activity#onActivityResult(int, int, Intent)} or * {@link android.support.v4.app.Fragment#onActivityResult(int, int, Intent)}. * Can be only one of {@link #REQUEST_CODE_CAMERA} or {@link #REQUEST_CODE_GALLERY}. * @param resultCode The result code from {@link Activity#onActivityResult(int, int, Intent)} or * {@link android.support.v4.app.Fragment#onActivityResult(int, int, Intent)}. * If {@link Activity#RESULT_OK}, the passed <var>data</var> will be processed, * otherwise {@code null} will be returned. * @param data The data from {@link Activity#onActivityResult(int, int, Intent)} or * {@link android.support.v4.app.Fragment#onActivityResult(int, int, Intent)}. * @param context Current valid context. * @param options Image options to adjust obtained bitmap. * @return Instance of Bitmap obtained from the given <var>data</var> Intent. */ @Nullable @SuppressWarnings("deprecation") public static Bitmap processResultIntent(int requestCode, int resultCode, @Nullable Intent data, @NonNull Context context, @Nullable ImageOptions options) { if (data == null || resultCode != Activity.RESULT_OK) { // User canceled the intent or no data are available. return null; } switch (requestCode) { case REQUEST_CODE_GALLERY: final Uri imageUri = data.getData(); Bitmap galleryImage = null; if (imageUri != null) { InputStream stream = null; try { stream = context.getContentResolver().openInputStream(imageUri); } catch (Exception e) { Log.e(TAG, "Unable to open image content at uri(" + imageUri + ").", e); } finally { if (stream != null) { if (options != null) { // Get the dimensions of the returned bitmap. final BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeStream(stream, null, bmOptions); final int bmWidth = bmOptions.outWidth; final int bmHeight = bmOptions.outHeight; // Compute how much to scale the bitmap. final int scaleFactor = Math.min(bmWidth / options.width, bmHeight / options.height); // Decode scaled bitmap. bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; galleryImage = BitmapFactory.decodeStream(stream, null, bmOptions); } else { galleryImage = BitmapFactory.decodeStream(stream); } try { stream.close(); } catch (IOException e) { Log.e(TAG, "Unable to close image content at uri(" + imageUri + ").", e); } } } } return galleryImage; case REQUEST_CODE_CAMERA: final Bundle extras = data.getExtras(); try { final Bitmap cameraImage = (extras != null) ? (Bitmap) extras.get("data") : null; if (cameraImage != null && options != null) { return Bitmap.createScaledBitmap(cameraImage, options.width, options.height, false); } return cameraImage; } catch (Exception e) { Log.e(TAG, "Failed to retrieve captured image.", e); } } return null; }
From source file:gxu.software_engineering.market.android.util.ServiceHelper.java
public static void doing(ContentResolver contentResolver, Intent intent) throws JSONException { String httpUri = intent.getStringExtra(C.HTTP_URI); Log.i("http uri", httpUri); JSONObject data = null;//from w w w. j ava2s . c om try { data = RESTMethod.get(httpUri); } catch (IOException e) { e.printStackTrace(); } Log.i("json result", data.toString()); JSONArray array = null; ContentValues[] items = null; switch (intent.getIntExtra(C.TARGET_ENTITY, -1)) { case CATEGORIES: array = data.getJSONArray(C.CATEGORIES); ContentValues[] categories = Processor.toCategories(array); contentResolver.bulkInsert(intent.getData(), categories); break; case LASTEST_USERS: array = data.getJSONArray(C.USERS); ContentValues[] users = Processor.toUsers(array); contentResolver.bulkInsert(intent.getData(), users); break; case LASTEST_ITEMS: array = data.getJSONArray(C.ITEMS); items = Processor.toItems(array); contentResolver.bulkInsert(intent.getData(), items); break; case HOTTEST_ITEMS: array = data.getJSONArray(C.ITEMS); items = Processor.toItems(array); contentResolver.bulkInsert(intent.getData(), items); break; case USER_ITEMS: array = data.getJSONArray(C.ITEMS); items = Processor.toItems(array); contentResolver.bulkInsert(intent.getData(), items); break; case CATEGORY_ITEMS: array = data.getJSONArray(C.ITEMS); items = Processor.toItems(array); contentResolver.bulkInsert(intent.getData(), items); break; case USER_CLOSED_ITEMS: array = data.getJSONArray(C.ITEMS); items = Processor.toItems(array); contentResolver.bulkInsert(intent.getData(), items); break; case USER_DEAL_ITEMS: array = data.getJSONArray(C.ITEMS); items = Processor.toItems(array); contentResolver.bulkInsert(intent.getData(), items); break; default: throw new IllegalArgumentException("sorry, 404 for the target!"); } }
From source file:com.facebook.AppLinkData.java
/** * Parses out any app link data from the Intent of the Activity passed in. * @param activity Activity that was started because of an app link * @return AppLinkData if found. null if not. *///w w w . ja va2s . c om public static AppLinkData createFromActivity(Activity activity) { Validate.notNull(activity, "activity"); Intent intent = activity.getIntent(); if (intent == null) { return null; } AppLinkData appLinkData = createFromAlApplinkData(intent); if (appLinkData == null) { String appLinkArgsJsonString = intent.getStringExtra(BUNDLE_APPLINK_ARGS_KEY); appLinkData = createFromJson(appLinkArgsJsonString); } if (appLinkData == null) { // Try regular app linking appLinkData = createFromUri(intent.getData()); } return appLinkData; }
From source file:be.e_contract.eid.android.BeIDBrowserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.browser_view); setTitle(R.string.browser_app_name); Intent intent = getIntent(); Uri uri = intent.getData(); String endpoint = uri.getSchemeSpecificPart(); new GetTask().execute(endpoint); }
From source file:com.commonsware.android.tuning.downloader.Downloader.java
@Override public void onHandleIntent(Intent i) { HttpGet getMethod = new HttpGet(i.getData().toString()); int result = Activity.RESULT_CANCELED; try {//from w w w . j a va2s . c om ResponseHandler<byte[]> responseHandler = new ByteArrayResponseHandler(); byte[] responseBody = client.execute(getMethod, responseHandler); File output = new File(Environment.getExternalStorageDirectory(), i.getData().getLastPathSegment()); if (output.exists()) { output.delete(); } FileOutputStream fos = new FileOutputStream(output.getPath()); fos.write(responseBody); fos.close(); result = Activity.RESULT_OK; } catch (IOException e2) { Log.e(getClass().getName(), "Exception in download", e2); } Bundle extras = i.getExtras(); if (extras != null) { Messenger messenger = (Messenger) extras.get(EXTRA_MESSENGER); Message msg = Message.obtain(); msg.arg1 = result; try { messenger.send(msg); } catch (android.os.RemoteException e1) { Log.w(getClass().getName(), "Exception sending message", e1); } } }