SDL: request Marshmallow SD card runtime permission using SDL_ANDROID_RequestExternalStorageRuntimePermission()

This commit is contained in:
pelya
2016-06-27 01:11:18 +03:00
parent 58558aa892
commit 7e032dd40a
8 changed files with 52 additions and 2 deletions

View File

@@ -53,6 +53,9 @@ import android.text.SpannedString;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.Manifest;
import android.content.pm.PackageManager;
class CountingInputStream extends BufferedInputStream
{
@@ -328,6 +331,19 @@ class DataDownloader extends Thread
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
if( url.indexOf("obb:") == 0 ) // APK expansion file provided by Google Play
{
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
{
int permissionCheck = Parent.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED && !Parent.writeExternalStoragePermissionDialogAnswered)
{
Parent.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
while( !Parent.writeExternalStoragePermissionDialogAnswered )
{
try{ Thread.sleep(300); } catch (InterruptedException e) {}
}
}
}
url = getObbFilePath(url);
InputStream stream1 = null;
try {