当前位置: 首页>>代码示例>>Java>>正文


Java Vibrator.vibrate方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:dhbw-timetable,项目名称:dhbw-timetable-android,代码行数:25,代码来源:AlarmSupervisor.java

示例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);
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:25,代码来源:NotificationShield.java

示例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);
    }
}
 
开发者ID:BANKEX,项目名称:smart-asset-iot-android-demo,代码行数:13,代码来源:MainActivity.java

示例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);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:10,代码来源:BeepManager.java

示例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();
        }
    }
}
 
开发者ID:ndleyton,项目名称:OneTwo,代码行数:16,代码来源:TouchDisplayView.java

示例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);
  }
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:10,代码来源:BeepManager.java

示例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);
    }
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:10,代码来源:BeepManager.java

示例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);
	}
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:10,代码来源:BeepManager.java

示例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);
    }
}
 
开发者ID:MRYangY,项目名称:YZxing,代码行数:10,代码来源:BeepManager.java

示例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);
    }
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:10,代码来源:BeepManager.java

示例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);
    }
}
 
开发者ID:CardInfoLink,项目名称:QRScanner,代码行数:10,代码来源:BeepManager.java

示例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();
  }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:12,代码来源:Afspiller.java

示例13: feedbackVibration

import android.os.Vibrator; //导入方法依赖的package包/类
public void feedbackVibration() {
    Vibrator vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(18);
}
 
开发者ID:IdeaTrackerPlus,项目名称:IdeaTrackerPlus,代码行数:5,代码来源:MainActivity.java

示例14: vibrate

import android.os.Vibrator; //导入方法依赖的package包/类
public static void vibrate(Context context) {
    Vibrator vibe = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibe.vibrate(100);
}
 
开发者ID:YUNEEC,项目名称:Yuneec-SDK-Android-Example,代码行数:5,代码来源:Media.java

示例15: makeVibrate

import android.os.Vibrator; //导入方法依赖的package包/类
public void makeVibrate(){
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    // Vibrate for 500 milliseconds
    v.vibrate(500);
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:6,代码来源:NotificationService.java


注:本文中的android.os.Vibrator.vibrate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。