Exemple #1
0
 /**
  * Vibrates the device for the given duration
  *
  * @param duration the duration in milliseconds
  * @return true when the vibration was activated successfully
  */
 public static boolean vibrate(int duration) {
   synchronized (vibrateLock) {
     boolean success = false;
     // #if polish.midp2 && polish.usePolishGui
     success = StyleSheet.display.vibrate(duration);
     // #elif polish.api.nokia-ui
     try {
       com.nokia.mid.ui.DeviceControl.startVibra(80, duration);
       success = true;
     } catch (IllegalStateException e) {
       // no vibration support
     }
     // #elif polish.api.samsung
     com.samsung.util.Vibration.start(duration, 100);
     success = com.samsung.util.Vibration.isSupported();
     // #endif
     return success;
   }
 }
Exemple #2
0
 /**
  * Checks if vibration can be controlled by the application
  *
  * @return true when the vibration can be controlled by the application
  */
 public static boolean isVibrateSupported() {
   synchronized (vibrateLock) {
     boolean isSupported = false;
     // #if polish.android
     isSupported = true;
     // #elif polish.blackberry
     isSupported = net.rim.device.api.system.Alert.isVibrateSupported();
     // #elif polish.api.nokia-ui && !polish.api.midp2
     try {
       com.nokia.mid.ui.DeviceControl.startVibra(0, 1);
       isSupported = true;
     } catch (IllegalStateException e) {
       // no vibration support
     }
     // #elif polish.api.samsung
     isSupported = com.samsung.util.Vibration.isSupported();
     // #elif polish.midp2 && polish.usePolishGui
     isSupported = StyleSheet.display.vibrate(0);
     // #endif
     return isSupported;
   }
 }