one more uri change

This commit is contained in:
Tibor Kaputa 2017-03-06 11:52:41 +01:00
parent 1c200cd2f5
commit eac2a37bad

View file

@ -4,10 +4,10 @@ import android.Manifest
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore import android.provider.MediaStore
import android.support.v4.app.ActivityCompat import android.support.v4.app.ActivityCompat
import android.support.v4.content.FileProvider
import android.support.v7.widget.GridLayoutManager import android.support.v7.widget.GridLayoutManager
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
@ -286,7 +286,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
if (requestCode == PICK_MEDIA && resultData != null) { if (requestCode == PICK_MEDIA && resultData != null) {
Intent().apply { Intent().apply {
val path = resultData.data.path val path = resultData.data.path
val uri = Uri.fromFile(File(path)) val uri = FileProvider.getUriForFile(this@MainActivity, "$packageName.provider", File(path))
if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) { if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) {
val type = File(path).getMimeType("image/jpeg") val type = File(path).getMimeType("image/jpeg")
setDataAndTypeAndNormalize(uri, type) setDataAndTypeAndNormalize(uri, type)