fix uploader on newer devices
This commit is contained in:
parent
116d6fe7ae
commit
061eff31f1
1 changed files with 9 additions and 31 deletions
|
@ -179,37 +179,14 @@ public class Uploader extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performFileSearch(String messageTitle) {
|
private void performFileSearch(String messageTitle) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
//uri = Uri.parse("content://com.android.externalstorage.documents/document/home");
|
||||||
sm = (StorageManager) this.getSystemService(Context.STORAGE_SERVICE);
|
intent = new Intent();
|
||||||
intent = sm.getPrimaryStorageVolume().createOpenDocumentTreeIntent();
|
intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
uri = intent.getParcelableExtra("android.provider.extra.INITIAL_URI");
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
//intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||||
String scheme = uri.toString();
|
//intent.putExtra("android.provider.extra.INITIAL_URI", uri);
|
||||||
|
intent.setType("*/*");
|
||||||
Log.d(TAG, "INITIAL_URI scheme: " + scheme);
|
((Activity) this).startActivityForResult(intent, 100);
|
||||||
|
|
||||||
scheme = scheme.replace("/root/", "/document/");
|
|
||||||
|
|
||||||
scheme += "%3A" + "Documents";
|
|
||||||
|
|
||||||
uri = Uri.parse(scheme);
|
|
||||||
|
|
||||||
intent.putExtra("android.provider.extra.INITIAL_URI", uri);
|
|
||||||
} else {
|
|
||||||
intent = new Intent();
|
|
||||||
intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
|
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
||||||
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
|
||||||
|
|
||||||
intent.setType("*/*");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
|
||||||
startActivityForResult(Intent.createChooser(intent, messageTitle), 100);
|
|
||||||
} else {
|
|
||||||
Toast.makeText(Uploader.this, getResources().getString(R.string.feature_not_supported), Toast.LENGTH_SHORT).show();
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -225,6 +202,7 @@ public class Uploader extends AppCompatActivity {
|
||||||
// provided to this method as a parameter. Pull that uri using "resultData.getData()"
|
// provided to this method as a parameter. Pull that uri using "resultData.getData()"
|
||||||
if (resultData != null && resultData.getData() != null) {
|
if (resultData != null && resultData.getData() != null) {
|
||||||
fileuri = resultData.getData();
|
fileuri = resultData.getData();
|
||||||
|
System.out.println(fileuri.toString());
|
||||||
//System.out.println("File selected successfully");
|
//System.out.println("File selected successfully");
|
||||||
//System.out.println("content://com.android.externalstorage.documents"+file.getPath());
|
//System.out.println("content://com.android.externalstorage.documents"+file.getPath());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue