List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.safecell.HomeScreenActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1) { if (resultCode == Activity.RESULT_OK) { Uri selectedImage = data.getData(); // Log.v("Safecell :" + "selectedImage", "imagePath = " // + selectedImage); profileImageView.setImageBitmap(getImageFromURI(selectedImage)); }/* w ww . jav a 2 s . c o m*/ } // //End Request code = 1 if (requestCode == 2 && resultCode == RESULT_OK) { Bitmap photo = (Bitmap) data.getExtras().get("data"); profileImageView.setImageBitmap(photo); } /* * if (requestCode == 2) { if (resultCode == -1) { * * if (outputFileUri == null) { //outputFileUri = (Uri) * data.getExtras().get(MediaStore.EXTRA_OUTPUT); * * Uri selectedImage = data.getData(); // Log.v("Safecell :" + * "selectedImage", "imagePath = " // + selectedImage); profileImageView * .setImageBitmap(getImageFromURI(selectedImage)); * * UIUtils.OkDialog(HomeScreenActivity.this, * "Capture image not available. outputuri: "+outputFileUri); * * } else { Uri selectedImage = Uri.parse(outputFileUri.getPath()); // * Log.v("Safecell :" + "selectedImage", "imagePath = " // + * selectedImage); profileImageView * .setImageBitmap(getImageFromURI(selectedImage)); } * * } } */ }
From source file:com.awrtechnologies.carbudgetsales.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { System.out.println("OnActivityResult"); Fragment tempFragment = GeneralHelper.getInstance(this).getTempFragment(); if (requestCode % 10 == 0 && resultCode == RESULT_OK) { String pathName = ""; Uri path = data.getData(); if (Build.VERSION.SDK_INT < 19) { pathName = getRealPathFromURI(this, path); } else {/*from w w w. j a v a 2 s.com*/ pathName = getRealPathFromURIUpdated(this, path); } System.out.println("selected file"); System.out.println("path " + pathName); if (requestCode == 10) { ((VehicleReceiptImages) tempFragment).onImageSelect(pathName); } // } else if (requestCode == 20) { // ((UpdateAccount) tempFragment).onImageSelect(pathName); // } } else if (requestCode % 10 != 0 && resultCode == RESULT_OK) { System.out.println("IMAGEPATH " + PreferencesManager.getPreferenceByKey(MainActivity.this, "IMAGEWWC")); imageFilePath = new File(PreferencesManager.getPreferenceByKey(MainActivity.this, "IMAGEWWC")); String pathName = imageFilePath.getAbsolutePath(); if (requestCode == 15) { ((VehicleReceiptImages) tempFragment).onImageSelect(pathName); } } }
From source file:net.bluecarrot.lite.MainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { //used to upload files // code for all versions except of Lollipop if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (requestCode == FILECHOOSER_RESULTCODE) { if (null == this.mUploadMessage) return; Uri result = null;/*www. j a v a 2s.c o m*/ try { if (resultCode != RESULT_OK) result = null; else { // retrieve from the private variable if the intent is null result = data == null ? mCapturedImageURI : data.getData(); } } catch (Exception e) { Toast.makeText(getApplicationContext(), "activity :" + e, Toast.LENGTH_LONG).show(); } mUploadMessage.onReceiveValue(result); mUploadMessage = null; } } // end of code for all versions except of Lollipop // start of code for Lollipop only if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (requestCode != FILECHOOSER_RESULTCODE || mFilePathCallback == null) { super.onActivityResult(requestCode, resultCode, data); return; } Uri[] results = null; // check that the response is a good one if (resultCode == Activity.RESULT_OK) { if (data == null || data.getData() == null) { // if there is not data, then we may have taken a photo if (mCameraPhotoPath != null) { results = new Uri[] { Uri.parse(mCameraPhotoPath) }; } } else { String dataString = data.getDataString(); if (dataString != null) { results = new Uri[] { Uri.parse(dataString) }; } } } mFilePathCallback.onReceiveValue(results); mFilePathCallback = null; } // end of code for Lollipop only }
From source file:br.com.anteros.vendas.gui.AnexoCadastroActivity.java
/** * Evento que retorna o resultado da chamada de outras activities. * @param requestCode Cdigo da requisio//from w w w .j a v a2s . c o m * @param resultCode Cdigo do resultado * @param data Dados */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { /** * Se a requiso era para tira foto. */ if (requestCode == TIRAR_FOTO) { if (resultCode == RESULT_OK) { try { new SalvaArquivoAnexo().execute(requestCode); } catch (Exception e) { e.printStackTrace(); new ErrorAlert(this, getResources().getString(R.string.app_name), "Ocorreu um erro ao salvar a foto. " + e.getMessage()).show(); } } /** * Se a requisio era para selecionar arquivo */ } else if (requestCode == SELECIONAR_ARQUIVO) { if (resultCode == RESULT_OK) { try { mUri = data.getData(); new SalvaArquivoAnexo().execute(requestCode); } catch (Exception e) { e.printStackTrace(); new ErrorAlert(this, getResources().getString(R.string.app_name), "Ocorreu um erro ao selecionar o arquivo. " + e.getMessage()).show(); } } } }
From source file:com.grass.caishi.cc.activity.SettingUserActivity.java
/** * onActivityResult//from w w w.ja v a 2 s .c o m */ public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == USERPIC_REQUEST_CODE_CAMERA) { // ? if (cameraFile != null && cameraFile.exists()) { Log.d("cameraFile" + cameraFile.getAbsolutePath()); // ?uri imageUri = Uri.fromFile(cameraFile); cropImageUri(Uri.fromFile(cameraFile), 300, 300, USERPIC_REQUEST_CODE_CUT); } } else if (requestCode == USERPIC_REQUEST_CODE_LOCAL) { // ? if (data != null) { Uri selectedImage = data.getData(); if (selectedImage != null) { cropImageUri(selectedImage, 300, 300, USERPIC_REQUEST_CODE_CUT); // Log.d("log","selectedImage"+selectedImage); } } } else if (requestCode == USERPIC_REQUEST_CODE_CUT) {// ? // ? if (data != null) { Bitmap bitmap = data.getParcelableExtra("data"); iv_user_photo.setImageBitmap(bitmap); File file = saveJPGE_After(bitmap, cameraFile); // ???? RequestParams params = new RequestParams(); if (file.exists()) { try { dialog.show(); params.put("logo", file, "image/jpeg"); // params.put("user", // MyApplication.getInstance().getUser()); params.put("type", "logo"); // params.add("uid", uid); HttpRestClient.post(Constant.UPDATE_USER_INFO_DO, params, responseHandler); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast toast = Toast.makeText(this, "?SD??", Toast.LENGTH_SHORT); } } else { // Log.e(TAG, "CHOOSE_SMALL_PICTURE: data = " + data); } } else if (resultCode == MainActivity.MAIN_MESSAGE_LOGIN_OUT) { setResult(resultCode); finish(); } }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
public void handlecontactBrowseData(Intent data) { Uri uriOfPhoneNumberRecord = data.getData(); String idOfPhoneRecord = uriOfPhoneNumberRecord.getLastPathSegment(); Cursor cursor = getContentResolver().query(Phone.CONTENT_URI, new String[] { Phone.NUMBER, Phone.DISPLAY_NAME }, Phone._ID + "=?", new String[] { idOfPhoneRecord }, null); if (cursor != null) { if (cursor.getCount() > 0) { cursor.moveToFirst();/* ww w . ja v a 2 s .c o m*/ String formattedPhoneNumber = cursor.getString(cursor.getColumnIndex(Phone.NUMBER)); Log.d("Contact Selected", formattedPhoneNumber + " &"); String formattedName = cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME)); Log.d("Contact Selected", formattedName + " &"); String contact_msg = "CON-" + formattedName + "-" + formattedPhoneNumber; MessageFragment.sendImage(contact_msg); } cursor.close(); } }
From source file:com.piusvelte.sonet.core.SonetComments.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (intent != null) mData = intent.getData(); if (mData == null) { (Toast.makeText(this, getString(R.string.failure), Toast.LENGTH_LONG)).show(); finish();/*w w w. j a v a2s .c om*/ } else { loadComments(); } }
From source file:com.grass.caishi.cc.activity.AdAddActivity.java
/** * onActivityResult/* w ww. ja v a 2s . c o m*/ */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { // ? if (requestCode == REQUEST_CODE_CAMERA) { // ?? if (cameraFile != null && cameraFile.exists()) if (select_type == 1) cropImageUri(Uri.fromFile(cameraFile), 450, 150, USERPIC_REQUEST_CODE_CUT); else addToListImage(cameraFile.getAbsolutePath()); // img_list.add(cameraFile.getAbsolutePath()); } else if (requestCode == REQUEST_CODE_IMAGES) { // ?? if (data != null) { Uri selectedImage = data.getData(); if (selectedImage != null) { if (select_type == 1) cropImageUri(selectedImage, 450, 150, USERPIC_REQUEST_CODE_CUT); else addToListImage(getPicByUri(selectedImage)); // img_list.add(getPicByUri(selectedImage)); } } } else if (requestCode == USERPIC_REQUEST_CODE_CUT) {// ? // ? if (data != null) { Bitmap bitmap = data.getParcelableExtra("data"); img_logo.setImageBitmap(bitmap); System.err.println(cameraFile.getAbsolutePath()); cameraFile = saveJPGE_After(bitmap, cameraFile); // // ???? addToListImage(cameraFile.getAbsolutePath()); } else { } } } }
From source file:terse.a1.TerseActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); glSurfaceView = null; // Forget gl on new activity. requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); if (savedInstanceState != null && savedInstanceState.containsKey("TerseActivity")) { taSaveMe = savedInstanceState.getString("TerseActivity"); } else {//from w w w.j ava2s. co m taSaveMe = null; } Runnable bg = new Runnable() { @Override public void run() { resetTerp(); } }; Runnable fg = new Runnable() { @Override public void run() { Intent intent = getIntent(); Uri uri = intent.getData(); Bundle extras = intent.getExtras(); String path = uri == null ? "/" : uri.getPath(); String query = uri == null ? "" : uri.getQuery(); viewPath(path, query, extras, savedInstanceState); } }; if (terp == null) { TextView tv = new TextView(TerseActivity.this); tv.setText(Static.fmt("Building new TerseTalk VM for world <%s>...", world)); tv.setTextAppearance(this, R.style.teletype); tv.setBackgroundColor(Color.BLACK); tv.setTextColor(Color.DKGRAY); tv.setTextSize(24); setContentView(tv); setContentViewThenBgThenFg("ResetSplash", tv, bg, fg); } else { fg.run(); } }
From source file:com.polyvi.xface.extension.camera.XCameraExt.java
public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (CAMERA_REQUEST_CODE == requestCode) { if (resultCode != Activity.RESULT_OK) { XLog.i(CLASS_NAME, "Camera cancelled."); mCallbackCtx.error("Camera cancelled."); return; }//from ww w. jav a 2s.c o m if (!mAllowEdit) { cameraSucess(intent); } else { startCutPhotoAfterCamera(intent); } } else if (PHOTO_REQUEST_CODE == requestCode) { if (resultCode != Activity.RESULT_OK || null == intent) { XLog.e(CLASS_NAME, "Selection cancelled."); mCallbackCtx.error("Selection cancelled."); return; } if (!mAllowEdit) { photoSucess(intent); } else { mImageUri = intent.getData(); startCutPhoto(mImageUri); } } else { if (resultCode != Activity.RESULT_OK || null == intent) { XLog.e(CLASS_NAME, "cut picture cancelled."); mCallbackCtx.error("cut picture cancelled."); return; } if (mSrcType == CAMERA) { cameraSucess(intent); } else if ((mSrcType == PHOTOLIBRARY) || (mSrcType == SAVEDPHOTOALBUM)) { photoSucess(intent); } } }