I've been struggling for few hours with reading notifications count in 
Android 6.0 Api level 23 but it doesn't want to work.I've made a panel with 
some leds and i want to lights up when I have notifications on my phone.The 
leds are controlled by an Arduino with an ethercard connected.And when I 
receive a notification,i want to acces a link to trigger the action on 
leds.This is the code but the onServiceConnected method is not called.What 
is the problem? The Arduino part and the server is working fine .



NotificationService.java

import android.accessibilityservice.AccessibilityService; import 
android.accessibilityservice.AccessibilityService; import 
android.accessibilityservice.AccessibilityServiceInfo; import 
android.view.accessibility.AccessibilityEvent; /** * Created by biabe on 
10/1/2016. */ public class NotificationService extends AccessibilityService { 
@Override public void onAccessibilityEvent(AccessibilityEvent event) { new 
HttpBackgroundWorker().execute(""); System.out.println("merge2"); } @Override 
public void onInterrupt() { // TODO Auto-generated method stub. 
System.out.println("merge3"); } @Override protected void onServiceConnected() { 
AccessibilityServiceInfo info = new AccessibilityServiceInfo(); 
info.feedbackType = 1; info.eventTypes = 
AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.notificationTimeout = 
100; setServiceInfo(info); System.out.println("merge"); } }

AndroidManifest

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" 
android:label="@string/app_name" android:supportsRtl="true" 
android:theme="@style/AppTheme"> <service android:name=".NotificationService" 
android:enabled="true" 
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> 
<intent-filter > <action android:name="android.intent.action.MAIN" /> <category 
android:name="android.intent.category.LAUNCHER" /> <action 
android:name="android.accessibilityservice.AccessibilityService"/> 
</intent-filter> </service> <activity android:name=".MainActivity"> 
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category 
android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/6681b2e7-4860-411b-b7eb-aeda51eb0bd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to