Comments (1)
解决了,android7.0,读取照片需要FileProvider.getUriForFile 问题
参考链接:https://blog.csdn.net/yy1300326388/article/details/52787853
把AndroidImagePicker类 takePicture方法修改如下:
public void takePicture(Fragment fragment, int requestCode) throws IOException {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//Intent takePictureIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
takePictureIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(fragment.getContext().getPackageManager()) != null) {
// Create the File where the photo should go
//File photoFile = createImageFile();
File photoFile = createImageSaveFile(fragment.getContext());
// Continue only if the File was successfully created
if (photoFile != null) {
Uri uri = null;
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N){
uri = FileProvider.getUriForFile(fragment.getContext(), "com.pizidea.imagepicker.fileprovider", photoFile);
}else {
uri = Uri.parse(photoFile.getAbsolutePath());
}
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,uri);
Log.i(TAG,"=====file ready to take photo:"+photoFile.getAbsolutePath() );
}
}
fragment.startActivityForResult(takePictureIntent, requestCode);
}
from androidimagepicker.
Related Issues (10)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidimagepicker.