2012-10-19 3 views
4

빌더 메소드를 통해 진행 상황을 보여주는 알림 표시 줄을 생성하고 싶습니다.하지만 어디에서 잘못되었는지 알 수있는 사람은 누구인지 알 수 없습니다. 감사 ..... 난 그냥 지금이 처리했다NotificationCompat.Builder에서 알림을받지 못합니다.

public class DownloadReceiver extends ResultReceiver{ 
    private final static String TAG = "DownloadReceiver"; 
    public Context context; 
    public DownloadReceiver(Handler handler,Context context) { 
     super(handler); 
     this.context = context; 
     Log.d(TAG,handler.getLooper().getThread().getName()); 
    } 

    @Override 
    protected void onReceiveResult(int resultCode, Bundle resultData) { 
     super.onReceiveResult(resultCode, resultData); 
     Log.d(TAG,"in download receiver"); 

     NotificationManager notificationManager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE); 
     Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com")); 
     PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notifyIntent, 0); 

    if(resultCode == DownloadService.COMPLETED){ 
      Log.d(TAG,resultCode + ""); 
      Builder notificationBuilder = new NotificationCompat.Builder(context) 
              .setProgress(100, 20, false) 
              .addAction(R.drawable.ic_action_search, "title", pendingIntent) 
              .setWhen(System.currentTimeMillis()); 
    //  notification.flags = Notification.FLAG_ONGOING_EVENT; 
      //  notification.setLatestEventInfo(context, "contentTitle", "contentText", pendingIntent); 
      notificationManager.notify(50, notificationBuilder.build()); 
     }else if(resultCode == DownloadService.ALLCOMPLETED){ 

     } 
    } 
} 

답변

11

, 나를 위해 솔루션 당신이 통지 이미지를 추가 할 필요가 있다고했다 그렇지 않으면

.setSmallIcon(R.drawable.launcher)

는하지 않습니다 아무것도 보여줘. 이전 알림 메서드는 기본적으로 앱 아이콘으로 설정되므로 직접 설정하지 않아도됩니다.

+0

답장을 보내 주셔서 감사합니다. 나는 해결책을 시도 할 것입니다. – user1361425

관련 문제