2017-12-13 3 views
0

알림을 빌드 할 때 잘못된 위치를 찾을 수 없습니다.Android 헤드 Up 알림이 표시되지 않습니다.

휴대 전화가 작동 중일 때 상단에 알림을 표시하고 휴대 전화가 잠자기 상태 인 경우 잠금 화면에 을 표시하려고합니다.

여기 제가 시도한 코드입니다. 그러나 결과를 얻을 수는 없습니다. 코드가 나를 위해 잘 작동처럼

PendingIntent pendingIntent = PendingIntent.getActivity(context,0, openIntent,PendingIntent.FLAG_UPDATE_CURRENT); 

NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "Normal") 
    .setSmallIcon(R.drawable.ic_folder) 
    .setContentIntent(pendingIntent) 
    .setPriority(NotificationCompat.PRIORITY_MAX) 
    .setCategory(NotificationCompat.CATEGORY_MESSAGE) 
    .setVibrate(new long[] {1000}) 
    .setContentTitle(mainListItem.getTitle()) 
    .setContentText(mainListItem.getDetail()) 
    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) 
    .setAutoCancel(true) 
    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); 


NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 

notificationManager.notify(0,builder.build()); 
+0

사용중인 sdk, 컴파일 및 최소 sdk 버전은 무엇입니까? –

+0

Min sdk 14, target and compile sdk 26 – kanudo

+0

문제는 버전 26부터 알림을 표시하기 위해 알림 채널을 만들어야합니다. 자세한 내용은 다음 링크를 확인하십시오. https://developer.android.com/guide/topics/ui/notifiers/notifications.html –

답변

0

그것은 말에 대답 할 수 있어요 ...

보이지만 몇 가지 이유를 들어 그 게재에 헤드 업 통지를 중지합니다.

  1. 그 통지를 당신의 머리를 비활성화되어있는 경우, 전화기 설정의 알림 센터와 같은 일부 시스템 설정에서 관리하는 것 현재 작업 응용 프로그램,하지 수 다음 머리까지 통지가 동일하게을 보여 있는지 확인하십시오 내 전화에서 알림 센터는 내 응용 프로그램의 알림을 선택하지 않거나 사용 안 함으로 설정합니다. "배너"(상태 표시 줄 맨 위에 표시) 설정은 휴대 전화에 응용 프로그램을 설치할 때 기본적으로 설정됩니다. 내 머리 위로 알림이 표시되지 않습니다. 을 확인하거나 사용하도록 설정해야합니다.

  2. 앱이 Android 버전 26 이상에서 실행되는 경우 알림 채널을 만들어 알림 설정을 확인해야 앱의 알림을 차단할 수 없습니다. 도움이 되길 바랍니다.

관련 문제