Skip to content

Commit

Permalink
Fixes NotificationListenerService not creating
Browse files Browse the repository at this point in the history
missing an i
  • Loading branch information
C0Newb committed Dec 2, 2022
1 parent 8e6c959 commit b3d4e7f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Client/Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".Backend.NotificationListenerService"
<service android:name="com.neptune.app.Backend.NotificationListenerService"
android:label="Neptune Notification Listener"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
android:exported="false">
<intent-filter>
<action android:name="android.service.notification.NotifcationListenerService" />
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public void onCreate() {
super.onCreate();
context = getApplicationContext();

startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
Log.d("NotificationListener", "Created.");

// Call this activity to ask the user to allow access .. but not from here, do it from the main activity or setup
//startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
// notificationServiceReceiver = new NotificationServiceReceiver();
//IntentFilter filter = new IntentFilter();
//filter.addAction("com.neptune.app.Backend");
Expand Down Expand Up @@ -78,13 +81,22 @@ public void onNotificationPosted(StatusBarNotification notification) {
ticker = notification.getNotification().tickerText.toString();
}


Bundle extras = notification.getNotification().extras;

Log.d("NotificationListener", "Notification from package: " + notification.getPackageName());
if (extras.getString("android.title") == null) { //Some notifications are not handled correctly, so we'll just skip em
return;
}

String title = extras.getString("android.title");
String text = extras.getCharSequence("android.text").toString();
String text = "";
if (extras.getCharSequence("android.text") != null) {
text = extras.getCharSequence("android.text").toString();
}
int id1 = extras.getInt(Notification.EXTRA_SMALL_ICON);
Bitmap id = notification.getNotification().largeIcon;

Log.i("Package", pack);
Log.i("Ticker", ticker);
Log.i("Title", title);
Log.i("Text", text);
Expand Down
2 changes: 1 addition & 1 deletion Client/Android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">NeptuneClientFrontEnd</string>
<string name="app_name">Neptune Client</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>

0 comments on commit b3d4e7f

Please sign in to comment.