Fixed crash and added more options to backup

This commit is contained in:
Prathamesh More 2021-10-23 21:31:33 +05:30
parent 75410bf77b
commit db3a7d4097
7 changed files with 171 additions and 26 deletions

View file

@ -0,0 +1,30 @@
package code.name.monkey.retromusic.util
import android.content.Context
import android.content.Intent
import android.widget.Toast
import androidx.core.content.FileProvider
import java.io.File
object BackupUtil {
fun createShareFileIntent(file: File, context: Context): Intent? {
return try {
Intent().setAction(Intent.ACTION_SEND).putExtra(
Intent.EXTRA_STREAM,
FileProvider.getUriForFile(
context,
context.applicationContext.packageName,
file
)
).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION).setType("*/*")
} catch (e: IllegalArgumentException) {
e.printStackTrace()
Toast.makeText(
context,
"Could not share this file.",
Toast.LENGTH_SHORT
).show()
Intent()
}
}
}