Reduce target SDK version from 26 to 23 so I can use file:// uris when sharing screenshots to other applications. >= 24 throws a android.os.FileUriExposedException when I try that.

If this causes problems in the future, I made a properly working ContentProvider implementation for screenshots in AndroidContentProvider branch. I tested and it does seem to work, although it's terribly written code and probably breaks somehow. Definitely not worth the two hours I wasted on that and FileProvider.
This commit is contained in:
UnknownShadow200 2020-09-27 22:56:09 +10:00
parent a466890ac3
commit 982d0bb925
3 changed files with 7 additions and 8 deletions

View file

@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
compileSdkVersion 23
defaultConfig {
applicationId = 'com.classicube.android'
minSdkVersion 13
targetSdkVersion 26
targetSdkVersion 23
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_static'

View file

@ -468,11 +468,10 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
public String shareScreenshot(String path) {
try {
File file = new File(getExternalAppDir() + path);
File file = new File(getExternalAppDir() + "/screenshots/" + path);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Check out my app.");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

View file

@ -571,12 +571,12 @@ void Game_TakeScreenshot(void) {
Chat_Add1("&eTaken screenshot as: %s", &filename);
#ifdef CC_BUILD_ANDROID
filename.length = 0;
JavaCall_String_String("shareScreenshot", &path, &filename);
if (!filename.length) return;
path.length = 0;
JavaCall_String_String("shareScreenshot", &filename, &path);
if (!path.length) return;
Chat_AddRaw("&cError sharing screenshot");
Chat_Add1(" &c%s", &filename);
Chat_Add1(" &c%s", &path);
#endif
#endif
}