mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Refactor check permission without supportv4 dependency
This commit is contained in:
@@ -104,13 +104,6 @@
|
||||
<artifactId>gdx-backend-android</artifactId>
|
||||
<version>1.9.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.android.support</groupId>
|
||||
<artifactId>support-v4</artifactId>
|
||||
<version>23.1.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${pom.basedir}/libs/android-support-v4.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.Gravity;
|
||||
@@ -145,10 +144,18 @@ public class Main extends AndroidApplication {
|
||||
super.onBackPressed();
|
||||
}
|
||||
private boolean checkPermission() {
|
||||
int result = ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (result == PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
} else {
|
||||
int pid = android.os.Process.myPid();
|
||||
int uid = android.os.Process.myUid();
|
||||
try {
|
||||
int result = this.getBaseContext().checkPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, pid, uid);
|
||||
//we only need the result above atm, we can free the dependency from android-support-v4 :)
|
||||
//int result = ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (result == PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user