List of usage examples for android.content Intent ACTION_GET_CONTENT
String ACTION_GET_CONTENT
To view the source code for android.content Intent ACTION_GET_CONTENT.
Click Source Link
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
/** * ?/*from w w w .j a va 2 s .co m*/ */ public void selectPicFromLocal() { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_CODE_LOCAL); }
From source file:com.grass.caishi.cc.activity.ChatActivity.java
/** * ?//from w ww . j av a 2s. c o m */ public void selectPicFromLocal() { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_CODE_LOCAL); }
From source file:com.inter.trade.ui.fragment.agent.AgentApplyFragmentNew.java
/*** * ?// w ww . j ava2 s . c o m */ private void pickPhoto() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO); }
From source file:com.ccxt.whl.activity.SettingsFragment.java
/** * ?// ww w . ja v a 2s .c om */ public void selectPicFromLocal() { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); //Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null); /*intent.setType("image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 600); intent.putExtra("outputY", 600); intent.putExtra("scale", true); intent.putExtra("return-data", false); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUritest); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); // no face detection */ //startActivityForResult(intent, CHOOSE_BIG_PICTURE); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); //startActivityForResult(intent, USERPIC_REQUEST_CODE_LOCAL_19); } startActivityForResult(intent, USERPIC_REQUEST_CODE_LOCAL); }
From source file:com.fa.mastodon.activity.ComposeActivity.java
private void initiateMediaPicking() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { intent.setType("image/* video/*"); } else {//from w ww. j ava2 s . c o m String[] mimeTypes = new String[] { "image/*", "video/*" }; intent.setType("*/*"); intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); } startActivityForResult(intent, MEDIA_PICK_RESULT); }
From source file:de.cachebox_test.splash.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override/*from w w w .j ava 2 s . c o m*/ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == Global.REQUEST_CODE_GET_WRITE_PERMISSION_ANDROID_5) { Uri treeUri = data.getData(); Intent intent = new Intent(Intent.ACTION_GET_CONTENT); final int takeFlags = intent.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Check for the freshest data. // Uri workPathUri = Uri.parse(workPath); ContentResolver cr = getContentResolver(); grantUriPermission(getPackageName(), treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION); cr.takePersistableUriPermission(treeUri, takeFlags); List<UriPermission> permissionlist = cr.getPersistedUriPermissions(); LolipopworkPath = "content://com.android.externalstorage.documents/tree/B8C5-760B%3A";// treeUri.getPath(); Thread th = new Thread(new Runnable() { @Override public void run() { Initial(width, height); } }); th.start(); } if (resultCode == RESULT_OK && requestCode == Global.REQUEST_CODE_PICK_FILE_OR_DIRECTORY_FROM_PLATFORM_CONECTOR) { if (resultCode == android.app.Activity.RESULT_OK && data != null) { // obtain the filename Uri fileUri = data.getData(); if (fileUri != null) { String filePath = fileUri.getPath(); if (filePath != null) { if (getFolderReturnListener != null) getFolderReturnListener.getFolderReturn(filePath); } } } return; } }
From source file:com.pimp.companionforband.activities.main.MainActivity.java
private void pickFromGallery() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN // Permission was added in API Level 16 && ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermission(Manifest.permission.READ_EXTERNAL_STORAGE, getString(R.string.permission_read_storage_rationale), REQUEST_STORAGE_READ_ACCESS_PERMISSION); } else {/* ww w. j a v a 2s.c om*/ Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent, getString(R.string.label_select_picture)), REQUEST_SELECT_PICTURE); } }
From source file:org.planetmono.dcuploader.ActivityUploader.java
private void initViews() { WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); if (wm.getDefaultDisplay().getOrientation() == 0) setContentView(R.layout.upload_portrait); else/*w w w . j a v a2 s .c o m*/ setContentView(R.layout.upload_landscape); EditText uploadTarget = (EditText) findViewById(R.id.upload_target); EditText uploadTitle = (EditText) findViewById(R.id.upload_title); EditText uploadText = (EditText) findViewById(R.id.upload_text); Button uploadVisit = (Button) findViewById(R.id.upload_visit); Button uploadPhotoTake = (Button) findViewById(R.id.upload_photo_take); Button uploadPhotoAdd = (Button) findViewById(R.id.upload_photo_add); Button uploadPhotoDelete = (Button) findViewById(R.id.upload_photo_delete); CheckBox uploadEnclosePosition = (CheckBox) findViewById(R.id.upload_enclose_position); Button uploadOk = (Button) findViewById(R.id.upload_ok); Button uploadCancel = (Button) findViewById(R.id.upload_cancel); /* set button behavior */ if (passThrough) uploadTarget.setClickable(false); else { uploadTarget.setClickable(true); registerForContextMenu(uploadTarget); } uploadTarget.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (!passThrough) openContextMenu(v); } }); registerForContextMenu(uploadVisit); uploadVisit.setOnClickListener(new OnClickListener() { public void onClick(View v) { openContextMenu(v); } }); uploadPhotoTake.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { tempFile = File.createTempFile("dcuploader_photo_", ".jpg"); } catch (IOException e) { Toast.makeText(ActivityUploader.this, " ?? .", Toast.LENGTH_SHORT).show(); tempFile = null; return; } Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (tempFile != null) i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); startActivityForResult(i, Application.ACTION_TAKE_PHOTO); } }); uploadPhotoAdd.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("image/*"); i.addCategory(Intent.CATEGORY_DEFAULT); startActivityForResult(i, Application.ACTION_ADD_PHOTO); } }); uploadPhotoDelete.setOnClickListener(new OnClickListener() { public void onClick(View v) { Gallery g = (Gallery) findViewById(R.id.upload_images); int pos = g.getSelectedItemPosition(); if (pos == -1) return; contents.remove(pos); bitmaps.remove(pos); updateGallery(); updateImageButtons(); if (contents.size() == 0) pos = -1; else if (pos >= contents.size()) --pos; g.setSelection(pos); } }); uploadOk.setOnClickListener(proceedHandler); uploadCancel.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); uploadEnclosePosition.setChecked(formLocation); uploadEnclosePosition.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { locationEnabled = isChecked; queryLocation(isChecked); } }); /* restore data when orientation changes */ if (formGallery != null) { if (target != null) { uploadTarget.setText(formGallery); formGallery = null; } } if (formTitle != null) { uploadTitle.setText(formTitle); formTitle = null; } if (formBody != null) { uploadText.setText(formBody); formBody = null; } updateImageButtons(); updateGallery(); }
From source file:com.hdu.tx.aschool.ui.activity.ChatActivity.java
/** * /*w w w. j a v a 2s. c o m*/ */ private void selectFileFromLocal() { Intent intent = null; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); } else { intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_CODE_SELECT_FILE); }
From source file:com.shengtao.chat.chatUI.activity.ChatActivity.java
/** * /*from w w w .ja v a 2s. c o m*/ */ private void selectFileFromLocal() { Intent intent = null; // if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); // } else { // intent = new Intent(Intent.ACTION_PICK, // android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); // } startActivityForResult(intent, REQUEST_CODE_SELECT_FILE); }