デバイスをバイブレーションさせる処理を統一
This commit is contained in:
parent
6a998d5718
commit
aca3a15686
|
@ -145,9 +145,16 @@ public class TestService extends Service {
|
||||||
return PendingIntent.getActivity(context, requestCode, intent, flags | PendingIntent.FLAG_IMMUTABLE);
|
return PendingIntent.getActivity(context, requestCode, intent, flags | PendingIntent.FLAG_IMMUTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void vibrateDevice() {
|
||||||
|
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
if (vibrator.hasVibrator()) {
|
||||||
|
vibrator.vibrate(VibrationEffect.createOneShot(2000, VibrationEffect.DEFAULT_AMPLITUDE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Notification(Context context) {//実際に通知を行うメソッド
|
public void Notification(Context context) {//実際に通知を行うメソッド
|
||||||
|
|
||||||
((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(2000);//バイブレーション
|
vibrateDevice();
|
||||||
|
|
||||||
@SuppressLint("NotificationTrampoline") NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
|
@SuppressLint("NotificationTrampoline") NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
|
||||||
.setSmallIcon(android.R.drawable.ic_menu_info_details)
|
.setSmallIcon(android.R.drawable.ic_menu_info_details)
|
||||||
|
@ -172,11 +179,7 @@ public class TestService extends Service {
|
||||||
if (ActivityCompat.checkSelfPermission(this,
|
if (ActivityCompat.checkSelfPermission(this,
|
||||||
android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) return;
|
android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) return;
|
||||||
|
|
||||||
|
vibrateDevice();
|
||||||
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
|
||||||
if (vibrator.hasVibrator()) {
|
|
||||||
vibrator.vibrate(VibrationEffect.createOneShot(2000, VibrationEffect.DEFAULT_AMPLITUDE));
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
|
||||||
.setSmallIcon(android.R.drawable.ic_menu_info_details)
|
.setSmallIcon(android.R.drawable.ic_menu_info_details)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user