Skip to content

Commit

Permalink
GameActivity: check for VIBRATE permission on Android
Browse files Browse the repository at this point in the history
While we add this permission by default, if a developer sets custom permissions, we want to avoid crashing when we try to access an API that we don't have permission to use
  • Loading branch information
joshtynjala committed Jan 7, 2025
1 parent 44dd331 commit 951d551
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Build;
Expand All @@ -16,6 +17,7 @@
import android.view.KeyEvent;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.Manifest;
import org.haxe.extension.Extension;
import org.libsdl.app.SDLActivity;

Expand Down Expand Up @@ -110,7 +112,13 @@ protected void onCreate (Bundle state) {
super.onCreate (state);

assetManager = getAssets ();
vibrator = (Vibrator)mSingleton.getSystemService (Context.VIBRATOR_SERVICE);

if (checkSelfPermission(Manifest.permission.VIBRATE) == PackageManager.PERMISSION_GRANTED) {

vibrator = (Vibrator)mSingleton.getSystemService (Context.VIBRATOR_SERVICE);

}

handler = new Handler ();

Extension.assetManager = assetManager;
Expand Down

0 comments on commit 951d551

Please sign in to comment.