2016-06-08 5 views
-1

이것은 내가 android studio에서 쓴 것입니다. 작동하지 않습니다. 알림이 표시되지 않습니다.이 알림 코드가 작동하지 않는 이유는 무엇입니까?

NotificationManager notificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE); 
    Intent i_mainActivity=new Intent(this,MainActivity.class); 
    PendingIntent p_mainActivity=PendingIntent.getActivity(this, 0, i_mainActivity, 0); 

    NotificationCompat.Builder notification_popup=new NotificationCompat.Builder(this) 
      .setContentTitle("An Alarm is going on") 
      .setContentText("Click to stop") 
      .setContentIntent(p_mainActivity) 
      .setAutoCancel(true); 
    int id=001; 
    notificationManager.notify(id,notification_popup.build()); 
+1

"작동하지 않는다"는 의미를 설명하십시오. 당신의 증상은 무엇입니까? – CommonsWare

답변

0

알림에 필수 구성 요소 인 아이콘이 누락되었습니다. Android에서 필수 구성 요소가 누락 된 경우 알림이 표시되지 않습니다. 특히

the Notifications documentation는 말한다 :

통지 객체가 있어야합니다 다음

  • setContentTitle 설정 setSmallIcon()
  • 제목, 설정 작은 아이콘()
  • setContentText()로 설정된 세부 텍스트
+0

작은 아이콘이 누락되었습니다. 고맙습니다:) –

관련 문제