Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.sw926.imagefileselector:library

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.sw926.imagefileselector:library

Android image file selector

  • 2.0.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

ImageFileSelector

轻量级的选取图片和裁切图片的库,使用系统自带的软件实现。

支持Android版本 Api Level >= 16

使用方法

implementation 'com.sw926.imagefileselector:library:2.0.0'

在 Activity 或者 Fragment Start 之前进行初始化:

mImageFileSelector = new ImageFileSelector(this);
mImageFileSelector.setOutPutImageSize(w, h);
mImageFileSelector.setQuality(80);
mImageFileSelector.setListener(new ImageFileResultListener() {
    @Override
    public void onSuccess(@NonNull String filePath) {
        loadImage(filePath);
        mCurrentSelectFile = new File(filePath);
        mBtnCrop.setVisibility(View.VISIBLE);
    }

    @Override
    public void onCancel() {
        Toast.makeText(ExampleActivity.this, "Canceled", Toast.LENGTH_LONG).show();
    }

    @Override
    public void onError() {
        Toast.makeText(ExampleActivity.this, "Unknown Error", Toast.LENGTH_LONG).show();
    }
});

在选择图片的地方调用:

mImageFileSelector.takePhoto();
// 或者
mImageFileSelector.selectImage();

说明

在 appcompat 支持 ActivityResultLauncher 后,选择图片已经非常简单,这个项目只是做了简单的封装,添加了拍照和图片压缩。选择图片不需要任何权限,如果 App 的 AndroidManifest.xml 没有添加 <uses-permission android:name="android.permission.CAMERA" /> ,拍照也不需要申请权限。

FAQs

Package last updated on 28 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc