List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:cliq.com.cliqgram.fragments.CameraFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Activity activity = getActivity();// w w w . j a va 2 s .co m if (requestCode == PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK && data != null && data.getData() != null) { /** * @param imageDate byte[] * @param currentUser User * @param description String * @return post Post * Note: Any data in post object may not be able to * get before post.saveInBackground() in finished. * So, check the database (table "Post") on Parse to see if post is * created successfully. * If post is created successfully, it will be shown on home page. */ Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver(), uri); // Log.d(TAG, String.valueOf(bitmap)); startImageDisplayActivity(bitmap); } catch (IOException e) { e.printStackTrace(); } } else { activity.finish(); } }
From source file:com.ibuildapp.romanblack.WebPlugin.WebPlugin.java
public void processResult(Intent data, int resultCode) { if (null == mUploadMessage) nullValueHandler();/*from w ww . j a v a 2 s . c om*/ Uri result = data == null || resultCode != RESULT_OK ? null : data.getData(); String filePath = result.getPath(); Uri fileUri = Uri.fromFile(new File(filePath)); if (isMedia) { ContentResolver cR = WebPlugin.this.getContentResolver(); MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getExtensionFromMimeType(cR.getType(result)); fileUri = Uri.parse(fileUri.toString() + "." + type); data.setData(fileUri); isMedia = false; } mUploadMessage.onReceiveValue(fileUri); mUploadMessage = null; }
From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Set view / call parent super.onCreate(savedInstanceState); setContentView(R.layout.activity_lydia); context = this; // Init intent flag INTENT_REQUEST intent_request = INTENT_REQUEST.ERROR; // Get intent parameters if (savedInstanceState == null) { Intent intent = getIntent(); Bundle extras = intent.getExtras(); String action = intent.getAction(); if (action != null) { // Check if intent's action is correct (obviously yes, but prevents Manifest modifications) if (action.equals(Intent.ACTION_VIEW)) { // Intent depuis Lydia intent_request = INTENT_REQUEST.FROM_LYDIA; // Get all parameters Uri qUri = intent.getData(); // Order ID String sOrderID = qUri.getQueryParameter("id"); if (sOrderID != null) { orderID = Integer.parseInt(sOrderID); }//from w w w.jav a2 s .co m orderType = qUri.getQueryParameter("cat"); } } else if (extras != null) { // Intent interne intent_request = INTENT_REQUEST.FROM_APP; orderID = extras.getInt(Constants.KEY_LYDIA_ORDER_ID); orderType = extras.getString(Constants.KEY_LYDIA_ORDER_TYPE); // Demande de check ? donc ask dj effectu if (extras.getBoolean(Constants.KEY_LYDIA_ORDER_ASKED)) { intent_request = INTENT_REQUEST.FROM_LYDIA; } } } // No intent received if (intent_request == INTENT_REQUEST.ERROR || orderID == -1) { Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show(); close(); } // Get objects userProfile = new UserProfile(); userProfile.readProfilePromPrefs(context); prefsUser = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); // Init dialog dialogInit(); // Get intent type if (intent_request == INTENT_REQUEST.FROM_APP) { /** * FROM_APP : On doit demander le numro de tlphone du client, puis lorsqu'il clique sur "Payer", effectuer une demande de paiement auprs de Lydia. * Il faut ensuite lancer l'Intent vers Lydia avec le bon numro de requte. * * A afficher : * - InputText tlphone * - Checkbox mmorisation numro * - Texte "lgal" sur le numro de tlphone * - Boutons Annuler / Valider AsyncTask ask.php */ dialogFromApp(); } else { /** * FROM_LYDIA : L'activit vient d'tre ouverte aprs que le client ait cliqu sur "Accepter" depuis l'app Lydia. * Dans 100% des cas, le retour notre activit se fait si il a eu un paiement valid. * Cependant, on vrifiera le statut de la commande auprs de notre serveur malgr tout. * * A afficher : * - Texte "tat de votre commande" titre dialogue * - Texte status : actualis toutes les 3 secondes asyncTask * - Bouton Fermer si status diffrent de "en cours" */ dialogFromLydia(); } }
From source file:com.game.simple.Game3.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (Session.getActiveSession() != null) Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); ////////////////////image//////////////////// if (resultCode != RESULT_OK) { return;/*from w w w .ja v a 2s . co m*/ } switch (requestCode) { case PICK_FROM_FILE: if (data == null) { Log.e("PICK_FROM_FILE", "NULL"); return; } selectedImage = data.getData(); cropImage(selectedImage); break; case PIC_CROP: if (data == null) { return; } Bundle extras = data.getExtras(); Bitmap thePic = extras.getParcelable("data"); Boolean isSDPresent = android.os.Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED); if (isSDPresent) { cropedImagePath = Environment.getExternalStorageDirectory().toString() + "/DCIM/avatar.jpeg"; } else { cropedImagePath = "mnt/emmc/avata.jpeg"; } Log.e("---------------path", cropedImagePath); FileOutputStream out = null; try { out = new FileOutputStream(cropedImagePath); thePic.compress(Bitmap.CompressFormat.JPEG, 90, out); } catch (Exception e) { e.printStackTrace(); } finally { try { out.close(); } catch (Throwable ignore) { } } break; case CAMERA_CAPTURE: cameraImage = data.getData(); if (cameraImage == null) { Log.e("CAMERA_CAPTURE", "NULL"); return; } cropImage(cameraImage); break; default: break; } }
From source file:com.slim.turboeditor.activity.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, final Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (resultCode == RESULT_OK) { if (requestCode == SELECT_FILE_CODE) { final Uri data = intent.getData(); File newFile = new File(data.getPath()); newFileToOpen(newFile, ""); } else {//from w w w . j ava2s . c om final Uri data = intent.getData(); final File newFile = new File(data.getPath()); // grantUriPermission(getPackageName(), // data, Intent.FLAG_GRANT_READ_URI_PERMISSION); // Check for the freshest data. getContentResolver().takePersistableUriPermission(data, (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)); if (requestCode == READ_REQUEST_CODE || requestCode == CREATE_REQUEST_CODE) { newFileToOpen(newFile, ""); } if (requestCode == SAVE_AS_REQUEST_CODE) { getSaveFileObservable(getApplicationContext(), newFile, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding) .subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<Boolean>() { @Override public void call(Boolean aBoolean) { savedAFile(aBoolean); newFileToOpen(newFile, ""); } }); } } } }
From source file:edu.cens.loci.ui.PlaceViewActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // parse incoming data final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { mUri = intent.getData(); if (mUri == null) { MyLog.e(LociConfig.D.ERROR, TAG, "intent.getData() is empty, exiting."); finish();//from w w w . j av a 2 s . co m } MyLog.d(LociConfig.D.UI.DEBUG, TAG, "mUri=" + mUri.toString()); } else { MyLog.e(LociConfig.D.ERROR, TAG, "Unknown action, exiting."); finish(); return; } mPlaceId = LociProvider.checkPlaceIdUri(mUri); if (mPlaceId < 0) { MyLog.e(LociConfig.D.ERROR, TAG, "Invalid uri, exiting."); finish(); } mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.place_view); mNameView = (TextView) findViewById(R.id.name); mMapView = (MapView) findViewById(R.id.map); mListView = (ListView) findViewById(R.id.place_data); mListView.setOnItemClickListener(this); mListView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); mListView.setEmptyView(findViewById(android.R.id.empty)); mDbUtils = new LociDbUtils(this); mPlace = mDbUtils.getPlace(mPlaceId); //DEBUG MyLog.d(LociConfig.D.UI.DEBUG, TAG, "viewing..." + mPlace.toString()); mHandler = new NotifyingAsyncQueryHandler(this, this); // The order they're added to mSections dictates the order they are diplayed in the list. mSections.add(mGpsEntries); mSections.add(mWifiEntries); mSections.add(mPostalEntries); mSections.add(mTagEntries); mSections.add(mWebsiteEntries); mSections.add(mOtherEntries); }
From source file:com.abc.driver.TruckActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CellSiteConstants.TAKE_PICTURE || requestCode == CellSiteConstants.PICK_PICTURE) { Uri uri = null;//from w w w . j a va2s . co m if (requestCode == CellSiteConstants.TAKE_PICTURE) { uri = imageUri; } else if (requestCode == CellSiteConstants.PICK_PICTURE) { uri = data.getData(); } String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(uri, filePathColumn, null, null, null); if (cursor != null && cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); Log.d(TAG, "filePath =" + filePath); Log.d(TAG, "uri=" + uri.toString()); imageUri = Uri.fromFile(new File(filePath)); } else // { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Toast.makeText(this, R.string.sdcard_occupied, Toast.LENGTH_SHORT).show(); return; } String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File tmpFile = new File(app.regUserPath + File.separator + "IMG_" + timeStamp + ".png"); File srcFile = new File(uri.getPath()); if (srcFile.exists()) { try { Utils.copyFile(srcFile, tmpFile); app.getUser().getMyTruck().setLicenseImageUrl(tmpFile.getAbsolutePath()); } catch (Exception e) { Toast.makeText(this, R.string.create_tmp_file_fail, Toast.LENGTH_SHORT).show(); return; } } else { Log.d(TAG, "Logic error, should not come to here"); Toast.makeText(this, R.string.file_not_found, Toast.LENGTH_SHORT).show(); return; } imageUri = Uri.fromFile(tmpFile); } // doCrop(); Bitmap tmpBmp = BitmapFactory.decodeFile(imageUri.getPath(), null); Bitmap scaledBmp = Bitmap.createScaledBitmap(tmpBmp, IMAGE_WIDTH, IMAGE_HEIGHT, false); mTLPiv.setImageBitmap(scaledBmp); isPortraitChanged = true; Log.d(TAG, "onActivityResult PICK_PICTURE"); mUpdateImageTask = new UpdateImageTask(); mUpdateImageTask.execute("" + app.getUser().getId(), "" + app.getUser().getMyTruck().getTruckId(), Utils.bitmap2String(scaledBmp), CellSiteConstants.UPDATE_TRUCK_LICENSE_URL); } else if (requestCode == CellSiteConstants.CROP_PICTURE) { Log.d(TAG, "crop picture"); // processFile(); if (data != null) { Bundle extras = data.getExtras(); Bitmap photo = extras.getParcelable("data"); trcukLicenseBmp = photo; mTLPiv.setImageBitmap(trcukLicenseBmp); mUpdateImageTask = new UpdateImageTask(); mUpdateImageTask.execute("" + app.getUser().getId(), "" + app.getUser().getMyTruck().getTruckId(), Utils.bitmap2String(trcukLicenseBmp), CellSiteConstants.UPDATE_DRIVER_LICENSE_URL); isPortraitChanged = true; } } else if (requestCode == CellSiteConstants.TAKE_PICTURE2 || requestCode == CellSiteConstants.PICK_PICTURE2) { Uri uri = null; if (requestCode == CellSiteConstants.TAKE_PICTURE2) { uri = imageUri; } else if (requestCode == CellSiteConstants.PICK_PICTURE2) { uri = data.getData(); } String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(uri, filePathColumn, null, null, null); if (cursor != null && cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); Log.d(TAG, "filePath =" + filePath); Log.d(TAG, "uri=" + uri.toString()); imageUri = Uri.fromFile(new File(filePath)); } else // { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Toast.makeText(this, R.string.sdcard_occupied, Toast.LENGTH_SHORT).show(); return; } String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File tmpFile = new File(app.regUserPath + File.separator + "IMG_" + timeStamp + ".png"); File srcFile = new File(uri.getPath()); if (srcFile.exists()) { try { Utils.copyFile(srcFile, tmpFile); app.getUser().getMyTruck().setPhotoImageUrl(tmpFile.getAbsolutePath()); } catch (Exception e) { Toast.makeText(this, R.string.create_tmp_file_fail, Toast.LENGTH_SHORT).show(); return; } } else { Log.d(TAG, "Logic error, should not come to here"); Toast.makeText(this, R.string.file_not_found, Toast.LENGTH_SHORT).show(); return; } imageUri = Uri.fromFile(tmpFile); } // doCrop(); Bitmap tmpBmp = BitmapFactory.decodeFile(imageUri.getPath(), null); Bitmap scaledBmp = Bitmap.createScaledBitmap(tmpBmp, IMAGE_WIDTH, IMAGE_HEIGHT, false); mTPiv.setImageBitmap(scaledBmp); // s isChanged = true; mUpdateImageTask = new UpdateImageTask(); mUpdateImageTask.execute("" + app.getUser().getId(), "" + app.getUser().getMyTruck().getTruckId(), Utils.bitmap2String(scaledBmp), CellSiteConstants.UPDATE_TRUCK_PHOTO_URL); } else if (requestCode == CellSiteConstants.UPDATE_TRUCK_MOBILE_REQUSET) { Log.d(TAG, "mobile changed"); if (app.getUser().getMyTruck().getMobileNum() == null) { mTMtv.setText(app.getUser().getMobileNum()); app.getUser().getMyTruck().setMobileNum(app.getUser().getMobileNum()); } else { mTMtv.setText(app.getUser().getMyTruck().getMobileNum()); } } }
From source file:com.buddi.client.dfu.DfuActivity.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode != RESULT_OK) return;//from w ww .j a va 2 s.com switch (requestCode) { case SELECT_FILE_REQ: // clear previous data mFileType = mFileTypeTmp; mFilePath = null; mFileStreamUri = null; // and read new one final Uri uri = data.getData(); /* * The URI returned from application may be in 'file' or 'content' schema. * 'File' schema allows us to create a File object and read details from if directly. * Data from 'Content' schema must be read by Content Provider. To do that we are using a Loader. */ if (uri.getScheme().equals("file")) { // the direct path to the file has been returned final String path = uri.getPath(); final File file = new File(path); mFilePath = path; updateFileInfo(file.getName(), file.length(), mFileType); } else if (uri.getScheme().equals("content")) { // an Uri has been returned mFileStreamUri = uri; // if application returned Uri for streaming, let's us it. Does it works? // FIXME both Uris works with Google Drive app. Why both? What's the difference? How about other apps like DropBox? final Bundle extras = data.getExtras(); if (extras != null && extras.containsKey(Intent.EXTRA_STREAM)) mFileStreamUri = extras.getParcelable(Intent.EXTRA_STREAM); // file name and size must be obtained from Content Provider final Bundle bundle = new Bundle(); bundle.putParcelable(EXTRA_URI, uri); //getSupportLoaderManager().restartLoader(0, bundle, this); getLoaderManager().restartLoader(0, bundle, this); } break; default: break; } }
From source file:com.hackensack.umc.fragment.ProfileSelfieActivityCustomeCam.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case Constant.FRAGMENT_CONST_REQUEST_IMAGE_CAPTURE: if (resultCode == RESULT_OK) { cropPictureIntent(imageUri); }// w ww . j a v a2 s.com break; case Constant.CROP_IMAGE_ACTIVITY: if (resultCode == RESULT_OK) { try { if (data != null) { imageUri = data.getData(); CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgSelfie, ProfileSelfieActivityCustomeCam.this); getImageUris(imageUri, 5); txtSefileSet.setText(R.string.done); } } catch (Exception e) { e.printStackTrace(); } } break; } }
From source file:com.github.gorbin.asne.instagram.InstagramSocialNetwork.java
/** * Overrided for Instagram support// w w w .ja v a2s. c o m * @param requestCode The integer request code originally supplied to startActivityForResult(), allowing you to identify who this result came from. * @param resultCode The integer result code returned by the child activity through its setResult(). * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { int sanitizedRequestCode = requestCode & 0xFFFF; if (sanitizedRequestCode != REQUEST_AUTH) return; super.onActivityResult(requestCode, resultCode, data); Uri uri = data != null ? data.getData() : null; if (uri != null && uri.toString().startsWith(mRedirectURL)) { String parts[] = uri.toString().split("="); String verifier = parts[1]; RequestLogin2AsyncTask requestLogin2AsyncTask = new RequestLogin2AsyncTask(); mRequests.put(REQUEST_LOGIN2, requestLogin2AsyncTask); Bundle args = new Bundle(); args.putString(RequestLogin2AsyncTask.PARAM_VERIFIER, verifier); requestLogin2AsyncTask.execute(args); } else { if (mLocalListeners.get(REQUEST_LOGIN) != null) { mLocalListeners.get(REQUEST_LOGIN).onError(getID(), REQUEST_LOGIN, "incorrect URI returned: " + uri, null); mLocalListeners.remove(REQUEST_LOGIN); } } }