Article Directory
1. Camera use
需要以下变量:
MediaStore.ACTION_IMAGE_CAPTURE
imgURI
file
具体参考:https://blog.csdn.net/hehe26/article/details/52921056?utm_source=blogxgwz38
2. Stream conversion (byte[] -> bitmap)
需要变量:
imgURI
InputStream-读出
ByteArrayOutputStream-写入
具体参考:https://www.cnblogs.com/yourancao520/archive/2012/06/25/2561367.html
3. Some problems
3.1 Return data as null
具体参考:startActivityForResult设置了Extra,设置URI会导致data返回null。不传URI则可以返回data。
3.2 Permission application
具体参考:Manifest.permission.CAMERA
3.3 Path setting
具体参考:fileProvider使用,涉及到meta-data标签
Refer to the following settings:
// Manifest.xml
<provider
android:authorities="${applicationId}.fileprovider"
android:name="androidx.core.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
//xml/file_paths.xml由于安全机制,所以需要(Android10)
<paths>
<cache-path
name="my_imgs_cache"
path="." />
</paths>
When setting, note that you can use different tags according to the path:
4. Reference suggestions
1. 《第一行代码》——
2. https://blog.csdn.net/hehe26/article/details/52921056?utm_source=blogxgwz38
3. https://blog.csdn.net/u014038534/article/details/52895686/
4. https://www.cnblogs.com/yourancao520/archive/2012/06/25/2561367.html
The predecessors planted trees, and the descendants took the shade.