2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-03 07:35:08 +00:00

Use ContextCompat.getSystemService() to retrieve system services without casting.

This commit is contained in:
Isira Seneviratne
2020-07-07 16:45:02 +05:30
parent f4ff5c3c89
commit 52aafe6b8c
25 changed files with 112 additions and 93 deletions

View File

@@ -396,7 +396,7 @@ public class Device implements BaseLink.PacketReceiver {
Resources res = getContext().getResources();
final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
final NotificationManager notificationManager = ContextCompat.getSystemService(getContext(), NotificationManager.class);
Notification noti = new NotificationCompat.Builder(getContext(), NotificationHelper.Channels.DEFAULT)
.setContentTitle(res.getString(R.string.pairing_request_from, getName()))
@@ -414,7 +414,8 @@ public class Device implements BaseLink.PacketReceiver {
}
public void hidePairingNotification() {
final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
final NotificationManager notificationManager = ContextCompat.getSystemService(getContext(),
NotificationManager.class);
notificationManager.cancel(notificationId);
}