I am a bit new to android development and was trying to make an application which listens to new notifications appearing on my device but when I go to enable the settings using the following statement, I don't get my app name in the settings. I have gone through the Android developers NotificationListenerService and added the service AndroidMainfest
. I open the settings activity by this Intent:
Intent intent = new Intent("android.settings.NOTIFICATION_LISTENER_SETTINGS");
The following is my NotificationListener class
public class NotificationListener extends NotificationListenerService {
private final String TAG = this.getClass().getSimpleName();
private final String Notification_Settings = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS";
@Override
public void onCreate() {
super.onCreate();
startActivity(new Intent(Notification_Settings));
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Bundle extras = sbn.getNotification().extras;
String title = extras.getString("android.title");
String text = extras.getCharSequence("android.text").toString();
Log.i(TAG, title + " " + text);
}
@Override
public IBinder onBind(Intent i) {
return super.onBind(i);
}
}
And finally, I call the service in the main activity
Intent i = new Intent(getApplicationContext(), NotificationListener.class);
startService(i);
I could not figure out what had I missed. Please help me. Thank you!
Edit:
Service in AndroidManifest
:
<service android:name=".NotificationListener"
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>
As pointed out by @Pawel I checked the manifest and noticed the 'L' in the
android:permission="android.permission.BIND_NOTIFICATION_lISTENER_SERVICE">
^
is a small one.