Add a hack to allow sharing files on newer android versions

Maybe fixes #46. It might not since it had no traceback.
This commit is contained in:
Lonami Exo 2020-08-30 12:17:55 +02:00
parent 7bc26d9a62
commit 5d88d63419

View file

@ -17,15 +17,31 @@
*/
package dev.lonami.klooni;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import java.lang.reflect.Method;
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// FIXME: Hack to allow us use the old way to share files
// https://stackoverflow.com/a/42437379/
if (Build.VERSION.SDK_INT >= 24) {
try {
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}
final AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
final AndroidShareChallenge shareChallenge = new AndroidShareChallenge(this);
initialize(new Klooni(shareChallenge), config);