本文整理汇总了Java中android.os.VibrationEffect类的典型用法代码示例。如果您正苦于以下问题:Java VibrationEffect类的具体用法?Java VibrationEffect怎么用?Java VibrationEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VibrationEffect类属于android.os包,在下文中一共展示了VibrationEffect类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import android.os.VibrationEffect; //导入依赖的package包/类
@Override
public void run() {
if (isPlaying) {
handler.postDelayed(this, interval);
if (emphasisIndex >= emphasisList.size())
emphasisIndex = 0;
boolean isEmphasis = emphasisList.get(emphasisIndex);
if (listener != null)
listener.onTick(isEmphasis, emphasisIndex);
emphasisIndex++;
if (soundId != -1)
soundPool.play(soundId, isEmphasis ? 1.0f : 0.2f, isEmphasis ? 1.0f : 0.2f, 0, 0, 1.0f);
else if (Build.VERSION.SDK_INT >= 26)
vibrator.vibrate(VibrationEffect.createOneShot(isEmphasis ? 50 : 20, VibrationEffect.DEFAULT_AMPLITUDE));
else vibrator.vibrate(isEmphasis ? 50 : 20);
}
}
开发者ID:TheAndroidMaster,项目名称:Metronome-Android,代码行数:20,代码来源:MetronomeService.java
示例2: onShake
import android.os.VibrationEffect; //导入依赖的package包/类
@Override
public void onShake() {
if (!isRecording) {
Vibrator vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
getManager().cancel(Const.SCREEN_RECORDER_WAITING_FOR_SHAKE_NOTIFICATION_ID);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
vibrate.vibrate(500);
else
VibrationEffect.createOneShot(500, 255);
startRecording();
Toast.makeText(this, "Rec start", Toast.LENGTH_SHORT).show();
} else {
Intent recordStopIntent = new Intent(this, RecorderService.class);
recordStopIntent.setAction(Const.SCREEN_RECORDING_STOP);
startService(recordStopIntent);
Toast.makeText(this, "Rec stop", Toast.LENGTH_SHORT).show();
mShakeDetector.stop();
}
}
开发者ID:vijai1996,项目名称:screenrecorder,代码行数:23,代码来源:RecorderService.java
示例3: vibrate
import android.os.VibrationEffect; //导入依赖的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: run
import android.os.VibrationEffect; //导入依赖的package包/类
@Override
public void run() {
if (isPlaying) {
if (soundId != -1)
soundPool.play(soundId, 1.0f, 1.0f, 0, 0, 1.0f);
else if (Build.VERSION.SDK_INT >= 26)
vibrator.vibrate(VibrationEffect.createOneShot(50, VibrationEffect.DEFAULT_AMPLITUDE));
else vibrator.vibrate(50);
handler.postDelayed(this, interval);
}
}
开发者ID:TheAndroidMaster,项目名称:Metronome-Android,代码行数:13,代码来源:MetronomeService.java
示例5: vibratorVibrate
import android.os.VibrationEffect; //导入依赖的package包/类
public static void vibratorVibrate(Vibrator vibratorService, long[] pattern, int repeat) {
if (Build.VERSION.SDK_INT >= 26) {
vibratorService.vibrate(VibrationEffect.createWaveform(pattern, repeat));
} else {
//noinspection deprecation
vibratorService.vibrate(pattern, repeat);
}
}
开发者ID:FranckRJ,项目名称:RespawnIRC-Android,代码行数:9,代码来源:Undeprecator.java
示例6: doVibrate
import android.os.VibrationEffect; //导入依赖的package包/类
public static void doVibrate(Vibrator v, int time) {
if (Build.VERSION.SDK_INT >= 26) {
v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
} else {
v.vibrate(time);
}
}
开发者ID:antest1,项目名称:kcanotify,代码行数:8,代码来源:KcaUtils.java
示例7: vibrate
import android.os.VibrationEffect; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@TargetApi(android.os.Build.VERSION_CODES.O)
private static void vibrate(Vibrator v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE));
} else {
v.vibrate(500);
}
}
开发者ID:TCA-Team,项目名称:TumCampusApp,代码行数:10,代码来源:ChatActivity.java
示例8: vibrate26
import android.os.VibrationEffect; //导入依赖的package包/类
@TargetApi(AndroidHelper.API_26)
@RequiresPermission(Manifest.permission.VIBRATE)
public static void vibrate26(final long[] durations, final boolean repeat) {
SystemServices.vibrator().vibrate(VibrationEffect.createWaveform(durations, (repeat ? DO_REPEAT : DO_NOT_REPEAT)));
}
开发者ID:shkschneider,项目名称:android_Skeleton,代码行数:6,代码来源:VibratorHelper.java
注:本文中的android.os.VibrationEffect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论