當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。