Back to project page shapemergency.
The source code is released under:
GNU General Public License
If you think the Android project shapemergency listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.adsg0186.shapemergency.testgame1; /*from w w w . j a v a2 s . c o m*/ import android.content.Context; import android.os.Vibrator; public class Vibrate { public static interface VibrateIF { public void vibrate(long ms); } private static class realVibrate implements VibrateIF { private Vibrator vibrator; public realVibrate(Context context) { vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); } @Override public void vibrate(long ms) { vibrator.vibrate(ms); } } private static class fakeVibrate implements VibrateIF { @Override public void vibrate(long ms) { } } private static VibrateIF realInstance; private static VibrateIF fakeInstance; private static VibrateIF instance; public static VibrateIF setRealInstance(Context context) { if (realInstance == null) { realInstance = new realVibrate(context); } instance = realInstance; return instance; } public static VibrateIF setFakeInstance() { if (fakeInstance == null) { fakeInstance = new fakeVibrate(); } instance = fakeInstance; return instance; } public static VibrateIF get() { return instance; } }