목록안드로이드스튜디오 (3)
dev_eun
[Android] 안드로이드 Vibrator 사용법
// 객체 선언 Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); // 진동 패턴 {멈춤1, 진동1, 멈춤2, 진동2, ...}; long[] pattern = {500, 2000, 500, 1000 }; // 진동 시작 vibrator.vibrate(pattern, 0); // 진동 멈춤 vibrator.cancel();
기타/안드로이드
2020. 2. 23. 20:20
[Android] 무음/진동 모드에서 벨,알람 울리기
지금 알람 앱을 만들고 있는데, 그냥 ringtone을 썼더니 소리모드가 아닐 때 소리가 나지 않았다. 그래서 찾아보니 많은 예제에서 setStreamType(int streamType) 을 사용하라고 나와있었는데 SDK 21부터 deprecated 되었다고 한다. 찾아보니 setAudioAttributes(AudioAttributes attributes) 이 함수로 대체되었다. - 예제 uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); ringtone = RingtoneManager.getRingtone(getApplicationContext(), uri); AudioAttributes audioAttributes = new AudioA..
기타/안드로이드
2020. 2. 17. 13:12