0

Android에서 실행 가능한 알림을 개발 중입니다.Android - 알림 표시 줄에 작업을 표시 할 수 없습니다.

void createActionableNotification() { 
    Intent intent = new Intent(this, MainActivity.class); 
    PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0); 

    // Build notification 
    // Actions are just fake 
    Notification noti = new NotificationCompat.Builder(this) 
      .setContentTitle("New mail from " + "[email protected]") 
      .setContentText("Subject").setSmallIcon(R.drawable.moneybag) 
      .setContentIntent(pIntent) 
      .addAction(R.drawable.moneybag, "Call", pIntent) 
      .addAction(R.drawable.moneybag, "More", pIntent) 
      .addAction(R.drawable.moneybag, "And more", pIntent).build(); 
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
    // hide the notification after its selected 

    noti.flags |= Notification.FLAG_AUTO_CANCEL; 

    notificationManager.notify(0, noti); 
} 

그래서 동작을 표시합니다. 아래 이미지를 확인하십시오. 앱이 대상 SDK와 함께 실행 해있다 enter image description here

는, 컴파일 SDK의 API (24)이며, 최소 SDK는 20 내가 마시 멜로 장치 테스트입니다. 하지만 에뮬레이터에서는 잘 작동합니다. 에뮬레이터 SDK 버전은 24 enter image description here

답변

0

이 시도 할 수 있습니다 : API를 작동> = 16

Notification notification = new Notification.Builder(myContext) 
.setContentTitle("New mail from " + "[email protected]") 
      .setContentText("Subject").setSmallIcon(R.drawable.moneybag) 
      .setContentIntent(pIntent) 
      .setPriority(Notification.PRIORITY_MAX) 
      .addAction(R.drawable.moneybag, "Call", pIntent) 
      .addAction(R.drawable.moneybag, "More", pIntent) 
      .addAction(R.drawable.moneybag, "And more", pIntent).build(); 

//The rest of your options 
.build(); 

목록에서 진행중인 Notification 현재는 미디어 플레이어 컨트롤로,이 때 버튼이 표시되지 않습니다 또는 당신은 응답에 대한 감사 전화가 USB를 통해 PC에 연결하거나 텍스트를 편집 할 때 ...

당신이이 문제를 얻을 Notification.PRIORITY_MAX을 시도 할 수 있습니다, 또는 PRIORITY_HIGH

+0

. 나는 Priority and setwhen (0)도 시도했다. 그러나 변화는 없습니다. 내 전화에 계속 알림이 없습니다. @ rafsanahmad007 – Roster

+0

알림에 스타일을 추가해보십시오. '.setStyle (새 NotificationCompat.BigTextStyle(). bigText (th_alert))' – rafsanahmad007

+0

다음을 참조하십시오. http://stackoverflow.com/questions/ 13720670/구현 - 확장 및 축소 알림 - android – rafsanahmad007