Giter Club home page Giter Club logo

Comments (3)

vtuan070978 avatar vtuan070978 commented on June 3, 2024 1

hi, I found the solution.
In the manifest file, I updated like below, it worked very well in Android 11.

  • <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
    
  •     tools:ignore="ScopedStorage"/>
    
  • <queries>
    
  •     <intent>
    
  •         <action android:name="android.media.action.IMAGE_CAPTURE" />
    
  •     </intent>
    
  •     <intent>
    
  •         <action android:name="android.media.action.VIDEO_CAPTURE" />
    
  •     </intent>
    
  • </queries>
    

Let's try it.

from android-filepicker.

vtuan070978 avatar vtuan070978 commented on June 3, 2024

hi, I had the solution for Android 11
I updated the lib at the function dispatchTakePictureIntent like this
fun dispatchTakePictureIntent(): Intent? {
val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
// Ensure that there's a camera activity to handle the intent
if (Build.VERSION.SDK_INT >=29) {
filephoto = getImageFile(File(mContext.getFilesDir(), "filepicker"))
val authority =
mContext.packageName + mContext.getString(R.string.image_picker_provider_authority_suffix)
photoURI = FileProvider.getUriForFile(mContext, authority, filephoto!!)
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
return takePictureIntent

    } else {
        if (takePictureIntent.resolveActivity(mContext.packageManager) != null) {
            // Create the File where the photo should go
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                filephoto = getImageFile(File(mContext.getFilesDir(), "filepicker"))
                val authority =
                        mContext.packageName + mContext.getString(R.string.image_picker_provider_authority_suffix)
                photoURI = FileProvider.getUriForFile(mContext, authority, filephoto!!)
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
            } else {
                filephoto = getImageFile(File(mContext.getExternalCacheDir(), "filepicker"))
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(filephoto))
            }
            return takePictureIntent
        }
    }
    return null
}

It worked well in Android 11
If you want the demo, let contact me via skype: vantuan2009

from android-filepicker.

zeeshanrasool91 avatar zeeshanrasool91 commented on June 3, 2024

un dispatchTakePictureIntent(): Intent? { val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) // Ensure that there's a camera activity to handle the intent if (Build.VERSION.SDK_INT >=29) { filephoto = getImageFile(File(mContext.getFilesDir(), "filepicker")) val authority = mContext.packageName + mContext.getString(R.string.image_picker_provider_authority_suffix) photoURI = FileProvider.getUriForFile(mContext, authority, filephoto!!) takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI) return takePictureIntent

    } else {
        if (takePictureIntent.resolveActivity(mContext.packageManager) != null) {
            // Create the File where the photo should go
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                filephoto = getImageFile(File(mContext.getFilesDir(), "filepicker"))
                val authority =
                        mContext.packageName + mContext.getString(R.string.image_picker_provider_authority_suffix)
                photoURI = FileProvider.getUriForFile(mContext, authority, filephoto!!)
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
            } else {
                filephoto = getImageFile(File(mContext.getExternalCacheDir(), "filepicker"))
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(filephoto))
            }
            return takePictureIntent
        }
    }
    return null
}

Hi can you share ImageCaptureManager file

from android-filepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.