当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ACTION_PICK属性代码示例

本文整理汇总了Java中android.content.Intent.ACTION_PICK属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_PICK属性的具体用法?Java Intent.ACTION_PICK怎么用?Java Intent.ACTION_PICK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_PICK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onOptionsItemSelected

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_load_image && read_external_storage_granted) {
        Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
        photoPickerIntent.setType("image/*");
        startActivityForResult(photoPickerIntent, SELECT_PHOTO);
        return true;
    } else if(!read_external_storage_granted) {
        Log.e("MainActivity", "pick image failed");
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:johnhany,项目名称:MOAAP,代码行数:16,代码来源:MainActivity.java

示例2: getPickImageIntent

public static Intent getPickImageIntent(Context context) {
    Intent chooserIntent = null;

    List<Intent> intentList = new ArrayList<>();

    Intent pickIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePhotoIntent.putExtra("return-data", true);
    takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(context)));
    intentList = addIntentsToList(context, intentList, pickIntent);
    intentList = addIntentsToList(context, intentList, takePhotoIntent);

    if (intentList.size() > 0) {
        chooserIntent = Intent.createChooser(intentList.remove(intentList.size() - 1),
                context.getString(R.string.pick_image));
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentList.toArray(new Parcelable[]{}));
    }

    return chooserIntent;
}
 
开发者ID:mirhoseini,项目名称:bcg,代码行数:21,代码来源:ImagePicker.java

示例3: selectPicture

/***
 * 选择一张图片
 * 图片类型,这里是image/*,当然也可以设置限制
 * 如:image/jpeg等
 *
 * @param activity Activity
 */
@SuppressLint("InlinedApi")
public void selectPicture(Activity activity) {
    try {
        //每次选择图片吧之前的图片删除
        clearCropFile(buildUri(activity));

        Intent intent = new Intent(Intent.ACTION_PICK, null);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");

        if (!isIntentAvailable(activity, intent)) {
            return;
        }
        activity.startActivityForResult(intent, INTENT_SELECT);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:24,代码来源:PhotoUtils.java

示例4: toGallery

/**
 * 跳转相册
 */
private void toGallery() {
    photoDialog.dismiss();
    Intent intent = new Intent(Intent.ACTION_PICK, null);
    intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
    startActivityForResult(intent, GALLERY_REQUEST);
}
 
开发者ID:HowieTianDev,项目名称:ChenYan,代码行数:9,代码来源:PublishAActivity.java

示例5: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mProgressDialog = new ProgressDialog(PickImageActivity.this);
    mProgressDialog.setMessage(getString(R.string.lc_please_wait));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCancelable(false);

    Intent startIntent = getIntent();
    if (savedInstanceState == null && startIntent != null) {
        mCropImage = startIntent.getBooleanExtra(EXTRA_CROP, false);
        mScale = startIntent.getBooleanExtra(EXTRA_SCALE, false);
        mScaleUp = startIntent.getBooleanExtra(EXTRA_SCALE_UP, false);
        if (startIntent.hasExtra(EXTRA_ASPECT_X) || startIntent.hasExtra(EXTRA_ASPECT_Y)) {
            mAspectSize = new Point(startIntent.getIntExtra(EXTRA_ASPECT_X, 0),
                    startIntent.getIntExtra(EXTRA_ASPECT_Y, 0));
        }
        if (startIntent.hasExtra(EXTRA_OUTPUT_X) || startIntent.hasExtra(EXTRA_OUTPUT_Y)) {
            mOutputSize = new Point(startIntent.getIntExtra(EXTRA_OUTPUT_X, 0),
                    startIntent.getIntExtra(EXTRA_OUTPUT_Y, 0));
        }
        if (startIntent.hasExtra(EXTRA_SPOTLIGHT_X) || startIntent.hasExtra(EXTRA_SPOTLIGHT_Y)) {
            mSpotlightSize = new Point(startIntent.getIntExtra(EXTRA_SPOTLIGHT_X, 0),
                    startIntent.getIntExtra(EXTRA_SPOTLIGHT_Y, 0));
        }

        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setType("image/*");
        startActivityForResult(Intent.createChooser(intent, getString(R.string.imgpick_dialog_title)),
                REQ_PICK_IMAGE);
    } else {
        finish();
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:35,代码来源:PickImageActivity.java

示例6: onClick

@Override
public void onClick(View v) {
  Intent intent = new Intent(Intent.ACTION_PICK);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  intent.setClassName(ShareActivity.this, BookmarkPickerActivity.class.getName());
  startActivityForResult(intent, PICK_BOOKMARK);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:7,代码来源:ShareActivity.java

示例7: demoStaticImage

@DebugLog
protected void demoStaticImage() {
    if (mTestImgPath != null) {
        Log.d(TAG, "demoStaticImage() launch a task to det");
        runDetectAsync(mTestImgPath);
    } else {
        Log.d(TAG, "demoStaticImage() mTestImgPath is null, go to gallery");
        Toast.makeText(MainActivity.this, "Pick an image to run algorithms", Toast.LENGTH_SHORT).show();
        // Create intent to Open Image applications like Gallery, Google Photos
        Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
    }
}
 
开发者ID:SimonCherryGZ,项目名称:face-landmark-android,代码行数:13,代码来源:MainActivity.java

示例8: openGallery

private void openGallery() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
            Toast.makeText(this, R.string.readStorageRequired, Toast.LENGTH_LONG).show();
        }
        else {
            ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_READ);
        }
        return;
    }
    Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    gallery.setType("image/*");
    startActivityForResult(gallery, REQUEST_PICK_IMAGE);
}
 
开发者ID:UTN-FRBA-Mobile,项目名称:Clases-2017c1,代码行数:14,代码来源:SelectPictureActivity.java

示例9: onClick

@Override
public void onClick(View v) {
    Intent intent = new Intent(Intent.ACTION_PICK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    intent.setClassName(ShareActivity.this, AppPickerActivity.class.getName());
    startActivityForResult(intent, PICK_APP);
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:7,代码来源:ShareActivity.java

示例10: changeAvatar

private void changeAvatar() {
    List<Intent> otherImageCaptureIntent = new ArrayList<>();
    List<ResolveInfo> otherImageCaptureActivities =
            getPackageManager().queryIntentActivities(new Intent(MediaStore.ACTION_IMAGE_CAPTURE),
                    0); // finding all intents in apps which can handle capture image
    // loop through all these intents and for each of these activities we need to store an intent
    for (ResolveInfo info : otherImageCaptureActivities) { // Resolve info represents an activity on the system that does our work
        Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        captureIntent.setClassName(info.activityInfo.packageName,
                info.activityInfo.name); // declaring explicitly the class where we will go
        // where the picture activity dump the image
        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempOutputFile));
        otherImageCaptureIntent.add(captureIntent);
    }

    // above code is only for taking picture and letting it go through another app for cropping before setting to imageview
    // now below is for choosing the image from device

    Intent selectImageIntent = new Intent(Intent.ACTION_PICK);
    selectImageIntent.setType("image/*");

    Intent chooser = Intent.createChooser(selectImageIntent, "Choose Avatar");
    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, otherImageCaptureIntent.toArray(
            new Parcelable[otherImageCaptureActivities.size()]));  // add 2nd para as intent of parcelables.

    startActivityForResult(chooser, REQUEST_SELECT_IMAGE);
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:27,代码来源:MessageActivity.java

示例11: startGallery

/**
 * Función que lanza el selector de imágenes de la galería, debe haberse dado el permiso
 * READ_EXTERNAL_STORAGE antes para abrir.
 */
public void startGallery() {
    Intent intent = new Intent(
            Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(
            Intent.createChooser(intent, getString(R.string.fragment_editar_datos_selecciona_una_imagen)),
            SELECT_FROM_GALLERY);
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:13,代码来源:EditarDatosFragment.java

示例12: startGallery

/**
 * Función que lanza el selector de imágenes de la galería, debe haberse dado el permiso
 * READ_EXTERNAL_STORAGE antes para abrir.
 */
public void startGallery() {
    Intent intent = new Intent(
            Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(
            Intent.createChooser(intent, "Selecciona una imagen"),
            SELECT_FROM_GALLERY);
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:13,代码来源:RegistrarFragment.java

示例13: openGallery

public void openGallery() {
    Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
    getIntent.setType("image/*");

    Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    pickIntent.setType("image/*");

    Intent chooserIntent = Intent.createChooser(getIntent, "Select An Image");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});

    startActivityForResult(chooserIntent, SELECT_PICTURE);
}
 
开发者ID:CatalystCode,项目名称:Custom-Vison-Service,代码行数:12,代码来源:MainActivity.java

示例14: btn_Palette

@OnClick(R.id.palette)
public void btn_Palette(View v) {
    Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(intent, RESULT_LOAD_IMAGE);
}
 
开发者ID:skydoves,项目名称:MagicLight-Controller,代码行数:5,代码来源:MainActivity.java

示例15: selectContactInfo

public static void selectContactInfo(Activity activity, int requestCode) {
  Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
  activity.startActivityForResult(intent, requestCode);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:4,代码来源:AttachmentManager.java


注:本文中的android.content.Intent.ACTION_PICK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。