안드로이드8.0에서 가장 짜증났던것은,
기존의 Notifications와 벳지카운터 메소드등등..
해당기능 사용법이 기존방식과 완전히 틀려졌다는 것이다
즉, 6.0이나 7.0이하에서 동작하는 기법이 8.0 이상부터는..안된다는것이다..
그리고..이클립스로 개발한다면 거의 포기하는게 나을 듯 싶다..
왠만하면 안드로이드 스튜디오로..
해당 구현방법 예제이다
int keyNumber = new Random().nextInt(2147483600); // notification 작업번호 지정, 작업번호가 같으면 덮어씌우기 처럼 되어 버린다.
PendingIntent pendingIntent = PendingIntent.getActivity(ctx.getApplicationContext(),0, new Intent() ,PendingIntent.FLAG_ONE_SHOT);
//실행하고자 하는 액티비티가 있으면 new Intent를 구현한다.
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "내가 원하는 체널ID, 문자열"; //기본 값, 오레오 이하 버전을 위해서
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { //오레오 이상
NotificationChannel channel = new NotificationChannel("그룹","채널", NotificationManager.IMPORTANCE_DEFAULT);
//그룹 및 채널은 내가 원하는 고유 키값으로 넣으면 된다.
channel.setShowBadge(true);
notificationManager.createNotificationChannel(channel);
channelId = channel.getId();
}
Notification notification = new NotificationCompat.Builder(ctx.getApplicationContext(), channelId)
.setContentTitle(title)
.setContentText(pushMsg)
.setSmallIcon(R.drawable.ic_launcher_background)
.setNumber(badgeCount)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setVibrate(new long[]{0, 500, 100})
.build();
notificationManager.notify(keyNumber, notification);
반응형
'기타 > Android' 카테고리의 다른 글
플레이 스토어 일시 정지 (0) | 2019.04.30 |
---|---|
안드로이드 앱 아이콘 변경 (0) | 2019.04.30 |
안드로이드 doze모드 만들기 (0) | 2019.04.30 |
안드로이드 Doze모드 (0) | 2019.04.30 |
안드로이드 Badge Count (0) | 2019.04.29 |
* 위 에니메이션은 Html의 캔버스(canvas)기반으로 동작하는 기능 입니다. Html 캔버스 튜토리얼 도 한번 살펴보세요~ :)
* 직접 만든 Html 캔버스 애니메이션 도 한번 살펴보세요~ :)
댓글