아마도이 문제는 내가 예상 한 것보다 간단합니다. 함수 내에서 생성 된 notification
을 표시하고 싶습니다. 디버깅 이유).이전 API 레벨 (예 : lvl 23)을 지원하는 Android 알림을 만드는 방법
Android Studio 3.0.1
(23) (이전 장치를 지원하기 위해) LVL API 및 알림 표시하는 제
규범 LVL API 광고와 Nexus5 장치에서 실행 :
PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
Notification notification = new NotificationCompat.Builder(this)
.setTicker("SomethingTicker")
.setSmallIcon(R.drawable.someImage)
.setContentTitle("SomeTitle")
.setContentText("SomeText")
.setContentIntent(pi)
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(001, notification);
NotificationCompat.Builder
그런 도시 컨텍스트 만 사용되지 않습니다. 최신 버전에서는 알림 채널을 사용해야합니다.
문제 : 알림 채널을 만들고 등록하려면 api lvl> 27을 사용해야합니다.
무엇이 누락 되었습니까? 그리고 가장 좋은 방법은 무엇입니까
참고 : 디버깅을 이유로 생성 시간이 다소 차이났습니다. 그것을 선택적 매개 변수로 설정하는 것이 좋습니다. 고맙습니다;) – schlenger
@schlenger : "디버깅을 위해 생성 시간이 다소 차이났습니다."- 아, 알겠습니다. – CommonsWare