티스토리 뷰
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "채널이름";
String description = "채널 디스크립션";
int 중요도 = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = null;
channel = new NotificationChannel("채널아이디", name, 중요도);
channel.setDescription (description);
//여기서 뱃지 여부 결정...
channel.setShowBadge(true);
// 시스템에 채널을 등록합니다. 중요성을 바꿀 수 없다.
// 또는이 후에 다른 알림 동작
NotificationManager notificationManager = null;notificationManager = getSystemService (NotificationManager.class);
notificationManager.createNotificationChannel (channel);
}
중요도는 알림을 길게 클릭하면 뭐가 나오는데 그거 임.. 소리 팝업 등 설정을 컨트롤 할 수있음
// 우리가 설정할 수 있는 중요도는 5단계고 그중 MIN이 아주 매력적인데 노티가 얇음 .. 마음에 들더라
채널 아이디는 노티 만들떄 아래와 같이 똑같아야 한다.
근데 이 채널이 한번 만들어지면 안드에서 재사용을 하는지 설정을 바꿔줘도 바뀌지가 않더라 이거때문에 좀 빡쳤는데
카카오톡도 컨트롤 못했어서 좀 풀림 ( 앱 설정에서 알림 끄고 노티 알림 켜면 알림 신나게 울림 )
디스크립션은 앱에서 길게 클릭하면 무슨 채널인지 설명? 할 수 있는 친절한 문구 셋해주는거..
하여튼 이렇게 채널을 만들어 준다...
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName(this, SettingSecurityActivity.class));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
PendingIntent contentIntent = PendingIntent.getActivity(this, 3, intent, PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder (this, "채널뭔데")
.setSmallIcon (R.drawable.ic_call_send_big)
.setContentTitle ("타이틀")
.setContentText ("내용텍스트")
.setContentIntent(contentIntent)
.setPriority (NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true)
.setBadgeIconType(1)
.setNumber(121);
//이 넘버는 각자의 넘버로...
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from (SettingSecurityActivity.this);
notificationManager.notify (123, mBuilder.build());
이렇게 펜딩인텐트와 노티를 만들어 준다..
디벨로퍼 사이트를 보니
contentTitle이랑 contentText랑 SmallIcon이 필수란다
이전엔 리모트뷰를 만들어 넣었어서 저 세개가 필요가 없었는데
저 세개를 안넣어서 뱃지가 안나오는 괴상망측한 상황이 발생했었다.
setBadgeIconType은 뱃지의 크기라는데 ... 차이가 없던데
하여튼 setNumber로 뱃지를 만들어 준다.
NotificationCompat.Builder 가 안될 땐
final Notification n = new Notification.Builder(mContext, nid)
.setContentIntent(contentIntent)
.setContentTitle (msg)
.setContentText("")
.setBadgeIconType(BADGE_ICON_LARGE)
.setSmallIcon (R.mipmap.ic_launcher)
.setNumber(숫자)
.setAutoCancel(true).build();
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from (mContext);
notificationManagerCompat.notify (nid, n));
이걸로 해보길..
난 위에껄로 안되고 이걸로 됨
위에걸로 따로 프로젝트 만들어서 헀을땐 됐는데...
오레오 극혐
'android' 카테고리의 다른 글
안드로이드 브로드캐스트 사용하기. (0) | 2018.12.12 |
---|---|
프리퍼런스 사용하기 (0) | 2018.11.19 |
노티 클릭 시 펜딩인텐트를 걸어서 백스택 만들기 (0) | 2018.10.02 |
드래그 해서 뷰 크기 조절하기 (0) | 2018.09.14 |
자바 특정 문자 막기 (한글 제외한 문자 받기) 천지인 키보드 ㅡ ㅣ 문제 (0) | 2018.08.29 |
- Total
- Today
- Yesterday
- React Native
- https://medium.com/@limgyumin/%EC%BD%94%ED%8B%80%EB%A6%B0-%EC%9D%98-apply-with-let-also-run-%EC%9D%80-%EC%96%B8%EC%A0%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%EA%B0%80-4a517292df29
- 귀찮아;;
- 함수형 코드
- ubunut 설치 link
- 구글 맵 경로 그리기
- mongo db
- not starting .bash_profile
- react native state
- not found adb
- text 부분 색 칠하기
- adb 환경변수
- not working adb
- https://hwan-shell.tistory.com/244
- 안드로이드
- rn
- insert
- mac android
- 차번호 정규식
- 구글 맵 선그리기
- ubunut android
- 자바
- spannableText
- MongoDB
- 차번호 정규표현식
- nosql
- 데이터베이스
- Android
- 명령어
- 클래스형 코드
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |