Browse Source

Minor changes.

Remove vibrate permission string, use Manifest.permission.VIBRATE instead!

Fix code style.

Set gamePath to empty when it fails to detect any game.love
Miku AuahDark 6 years ago
parent
commit
117bba5ff2
1 changed files with 7 additions and 4 deletions
  1. 7 4
      love/src/main/java/org/love2d/android/GameActivity.java

+ 7 - 4
love/src/main/java/org/love2d/android/GameActivity.java

@@ -75,8 +75,7 @@ public class GameActivity extends SDLActivity {
 
         context = this.getApplicationContext();
 
-        String permission = "android.permission.VIBRATE";
-        int res = context.checkCallingOrSelfPermission(permission);
+        int res = context.checkCallingOrSelfPermission(Manifest.permission.VIBRATE);
         if (res == PackageManager.PERMISSION_GRANTED) {
             vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
         } else {
@@ -129,8 +128,7 @@ public class GameActivity extends SDLActivity {
                     String destination_file = this.getCacheDir().getPath() + "/game.love";
                     InputStream data = getContentResolver().openInputStream(game);
                     // copyAssetFile automatically closes the InputStream
-                    if (copyAssetFile(data, destination_file))
-                    {
+                    if (copyAssetFile(data, destination_file)) {
                         gamePath = destination_file;
                         storagePermissionUnnecessary = true;
                     }
@@ -179,7 +177,12 @@ public class GameActivity extends SDLActivity {
                     storagePermissionUnnecessary = true;
                 } catch (IOException e) {
                     Log.d("GameActivity", "Could not open game.love from assets: " + e.getMessage());
+                    gamePath = "";
+                    storagePermissionUnnecessary = false;
                 }
+            } else {
+                gamePath = "";
+                storagePermissionUnnecessary = false;
             }
         }