2014년 1월 28일 화요일

Notification()이 아닌 NotificationCompat 사용시 에러.

  notification.when = System.currentTimeMillis();
  notification.icon = res.getIdentifier("com.dj.NEWCLEAR:drawable/app_icon", null, null);
  notification.defaults = Notification.DEFAULT_ALL;
  //notification.vibrate = new Long[]{100, 50, 100, 50};
  notification.flags |= Notification.FLAG_AUTO_CANCEL;
  notification.tickerText = "스틱 교체가 필요합니다.";
  notification.setLatestEventInfo(arg0, strTitle, strMsg, pendingIntent);

Notification() 사용시에 지금은 크게 문제가 없으나.
setLatestEventInfo 함수는 곧 패기(?)된다 ㅠㅠ

따라서 이후 버전에서도 지원이 되는 API를 사용하여야 하는대.

  Resources res = getResources();
  Notification notification = new NotificationCompat.Builder(arg0)
  .setContentTitle("NEWCLEAR")
  .setContentText("NEWCLEAR - 스틱 교체가 필요합니다.")
  .setSmallIcon(res.getIdentifier("com.dj.NEWCLEAR:drawable/app_icon", null, null))
  .setDefaults(Notification.DEFAULT_ALL)
  .setAutoCancel(true)
  .setTicker("NEWCLEAR - 스틱 교체가 필요합니다.")
  .setContentIntent(pendingIntent)
  .build();

NotificationCompat 객체를 사용하면 된다고 한다.

그래서 이  API를 이용해 push를 했으나.. push 메세지는 깜깜무소식..

LogCat에서 오류를 보니

at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)

이라는 오류가 있었다.

그리고 검색해보니

There is a support library bug filed for this, see here. A fixed v4 support library can be downloaded fromthis link in comment #2.

버그가 있다는것이다...(아마 최신버전의 sdk를 즉각즉각 업데이트 하신분은 이런 문제가 없으실듯)

다른 분의 말에 따르면
 
This is a known bug in android-support-v4.jar before rev11.
To get the latest android-support-v4.jar:
 
즉 rev11 이하의 버전에서만 가지고 있는 버그라고 한다. 즉시 업데이트 해주도록 하자.
 
 
 

댓글 없음:

댓글 쓰기