本文整理汇总了Java中android.os.Vibrator.vibrate方法的典型用法代码示例。如果您正苦于以下问题:Java Vibrator.vibrate方法的具体用法?Java Vibrator.vibrate怎么用?Java Vibrator.vibrate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Vibrator
的用法示例。
在下文中一共展示了Vibrator.vibrate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startVibrator
import android.os.Vibrator; //导入方法依赖的package包/类
void startVibrator(Context context) {
Log.d("VIB", "Trying to vibrate...");
// Get instance of Vibrator from current Context
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
SharedPreferences sharedPreferences = context.getSharedPreferences(
context.getString(R.string.preference_file_key), Context.MODE_PRIVATE);
long[][] patterns = {
{0, 1000, 100, 1000, 100, 1000, 100, 1000, 100},
{0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}};
int patternIndex = sharedPreferences.getInt("alarmVibrationIndex", 0);
switch (patternIndex) {
case 0:
break;
case 1:
case 2:
if (vibrator != null) {
vibrator.vibrate(patterns[patternIndex - 1], 0);
}
break;
}
}
示例2: showNotification
import android.os.Vibrator; //导入方法依赖的package包/类
protected void showNotification(String notificationText) {
// TODO Auto-generated method stub
NotificationCompat.Builder build = new NotificationCompat.Builder(
activity);
build.setSmallIcon(OneSheeldApplication.getNotificationIcon());
build.setContentTitle(notificationText);
build.setContentText(activity.getString(R.string.notifications_notification_received_from_1sheeld));
build.setTicker(notificationText);
build.setWhen(System.currentTimeMillis());
Toast.makeText(activity, notificationText, Toast.LENGTH_SHORT).show();
Vibrator v = (Vibrator) activity
.getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(1000);
Intent notificationIntent = new Intent(activity, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(activity, 0,
notificationIntent, 0);
build.setContentIntent(intent);
Notification notification = build.build();
NotificationManager notificationManager = (NotificationManager) activity
.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(2, notification);
}
示例3: vibrate
import android.os.Vibrator; //导入方法依赖的package包/类
private void vibrate(long millis) {
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (v != null) {
v.vibrate(millis);
}
} else {
VibrationEffect effect =
VibrationEffect.createOneShot(millis, VibrationEffect.DEFAULT_AMPLITUDE);
v.vibrate(effect);
}
}
示例4: playBeepSoundAndVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
synchronized void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
示例5: checkGlobalVariable
import android.os.Vibrator; //导入方法依赖的package包/类
public void checkGlobalVariable(){
if (fingersDown){
if (!alreadyChosen) {
alreadyChosen = true;
randomArray = intArrayToN(mTouches.size());
shuffleArray(randomArray);
chosenId = randomArray[0];
chosenColor = COLORS[chosenId % COLORS.length];
Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = {0,20,10,50};
v.vibrate(pattern, -1);
invalidate();
}
}
}
示例6: playBeepSoundAndVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
public synchronized void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
示例7: playBeepSoundAndVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
public void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
示例8: playBeepSoundAndVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
public synchronized void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
示例9: playBeepSoundAndVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
synchronized void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
示例10: playBeepSoundAndVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
public synchronized void playBeepSoundAndVibrate() {
if (beepEnabled) {
playBeepSound();
}
if (vibrateEnabled) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
示例11: playBeepSoundAndVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
public synchronized void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
示例12: vibru
import android.os.Vibrator; //导入方法依赖的package包/类
private void vibru(int ms) {
Log.d("vibru " + ms);
try {
Vibrator vibrator = (Vibrator) ApplicationSingleton.instans.getSystemService(Activity.VIBRATOR_SERVICE);
vibrator.vibrate(ms);
// Tenu telefonon veka por 1/2a sekundo
AlarmAlertWakeLock.createPartialWakeLock(ApplicationSingleton.instans).acquire(500);
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: feedbackVibration
import android.os.Vibrator; //导入方法依赖的package包/类
public void feedbackVibration() {
Vibrator vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(18);
}
示例14: vibrate
import android.os.Vibrator; //导入方法依赖的package包/类
public static void vibrate(Context context) {
Vibrator vibe = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(100);
}
示例15: makeVibrate
import android.os.Vibrator; //导入方法依赖的package包/类
public void makeVibrate(){
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// Vibrate for 500 milliseconds
v.vibrate(500);
}