mirror of
https://github.com/love2d/love-android.git
synced 2026-08-20 04:31:26 +02:00
Stop the vibrator when the app is paused (e.g. when device is switched off or app goes in background)
This commit is contained in:
@@ -56,6 +56,20 @@ public class GameActivity extends SDLActivity {
|
|||||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
Log.d("GameActivity", "Cancelling vibration");
|
||||||
|
vibrator.cancel();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
Log.d("GameActivity", "Cancelling vibration");
|
||||||
|
vibrator.cancel();
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
public static String getGamePath() {
|
public static String getGamePath() {
|
||||||
Log.d ("GameActivity", "called getGamePath(), game path = " + gamePath);
|
Log.d ("GameActivity", "called getGamePath(), game path = " + gamePath);
|
||||||
return gamePath;
|
return gamePath;
|
||||||
@@ -66,7 +80,6 @@ public class GameActivity extends SDLActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void vibrate (double seconds) {
|
public static void vibrate (double seconds) {
|
||||||
Log.d ("GameActivity", "vibrating for " + seconds + " seconds");
|
|
||||||
vibrator.vibrate((long) (seconds * 1000.));
|
vibrator.vibrate((long) (seconds * 1000.));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user