Dưới đây là mã của tôi để nắm bắt thông báo. Tôi không hiểu tại sao số điện thoại onNotificationPosted không bị sa thải.NotificationListenerService không hoạt động - ngay cả sau khi cho phép
Tôi cho ứng dụng của tôi Notifications truy cập từ Cài đặt> Bảo mật và onCreate từ MyNotifService cũng bị sa thải, nhưng onNotificationPosted không bị sa thải.
Tôi đang thiếu hoặc làm gì sai?
Từ tôi MainActivity của onCreate() chức năng:
Intent intent = new Intent(this, MyNotifService.class);
this.startService(intent);
mã dịch vụ của tôi mà kéo dài NotificationListenerService:
@SuppressLint("NewApi")
public class MyNotifService kéo dài NotificationListenerService {
@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");
}
}
Trong file manifest, tôi có điều này:
<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>
FOUND FIX: Đã phải khởi động điện thoại. Tìm thấy một liên kết mà một người nào đó đã đăng thông tin này và chi tiết về lỗi, nếu tôi tìm thấy nó một lần nữa - sẽ đăng ở đây. – user1406716
Bắt đầu? Bạn có nghĩa là "khởi động lại"? – jaytj95
có thể sự cố này ở đây: https://code.google.com/p/android/issues/detail?id=62811 – Jareddlc