2014-12-13 3 views
6

다음은 알림을 캡처하는 코드입니다. 나는 onNotificationPosted가 해고되지 않는 이유를 이해하지 못한다. NotificationListenerService가 작동하지 않습니다 - 권한을 부여한 후에도

나는 알림 설정> 보안에서 접근도 해고되는 MyNotifService에서 에서 onCreate 내 응용 프로그램을 제공하고 있지만, 가 해고되지 onNotificationPosted.

무엇이 잘못되었거나 잘못 되었습니까?

@SuppressLint("NewApi") 

공용 클래스 MyNotifService가 {

@Override 
public void onNotificationPosted(StatusBarNotification sbn) { 
    super.onNotificationPosted(sbn);   
    Log.v("focus", "in onNotificationPosted() of MyNotifService");  
} 

@Override 
public void onCreate() { 
    super.onCreate();  
    Log.v("focus", "in onCreate() of MyNotifService");  
} 

} 
NotificationListenerService를 확장 : NotificationListenerService 확장

Intent intent = new Intent(this, MyNotifService.class); 
    this.startService(intent); 

내 서비스 코드 : 내 MainActivity의에서 onCreate() 기능에서

매니페스트 파일에서

,이 있습니다

+5

FOUND FIX :에 있었다 전화를 시작하십시오. 다른 사람이 버그를 게시 한 링크를 찾았습니다. 다시 찾으면 여기에 게시됩니다. – user1406716

+0

시작 하시겠습니까? "다시 시작"하시겠습니까? – jaytj95

+0

아마도 여기에서이 문제가 발생할 수 있습니다. https://code.google.com/p/android/issues/detail?id=62811 – Jareddlc

답변

2

조금 flakey 것으로 보인다 있지만,이 경우의 실제 수정입니다

<service 
     android:name="com.mavdev.focusoutfacebook.notifications.MyNotifService" 
     android:label="@string/app_name" 
     android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > 
     <intent-filter> 
      <action android:name="android.service.notification.NotificationListenerService" /> 
     </intent-filter> 
    </service> 
:

@Override 
public IBinder onBind(Intent intent) { 
    return super.onBind(intent); 
} 
+1

해결 방법에 대해 설명해주세요. 서비스가 실제로 묶이는 지 확인하는 것입니까? – Paritosh

+0

'onBind()'가 오버라이드되지 않으면,'super.conBind()'자체가 호출되어야합니다. 어떻게이 오버라이드가 어떤 차이를 만들 수 있습니까? –

+0

@SteveBlackwell 당신이 맞습니다,이 대답은 차이를 가져서는 안됩니다. 무슨 일이 일어 났는지는 내가 포스터와 비슷한 문제에 부딪쳤다는 것과 문제는 내가 명시 적으로 슈퍼 생성자를 호출하지 않는다는 것이 었습니다. 나는 포스터가 NotificationListenerService의이 부분을 질문에서 제외하고 같은 문제가 있다고 생각했지만 기억이 안납니다. – RyPope

관련 문제