Use ContextCompat.getSystemService() and the Context.getSystemService() extension function.

This commit is contained in:
Isira Seneviratne 2020-09-13 17:20:29 +05:30
parent f4620be859
commit 58b720b004
17 changed files with 61 additions and 43 deletions

View file

@ -24,6 +24,8 @@ import android.os.Handler.Callback;
import android.os.IBinder;
import android.os.Message;
import android.os.Parcelable;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
import android.util.Log;
import android.util.SparseArray;
@ -157,8 +159,10 @@ public class DownloadManagerService extends Service {
mNotification = builder.build();
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mNotificationManager = ContextCompat.getSystemService(this,
NotificationManager.class);
mConnectivityManager = ContextCompat.getSystemService(this,
ConnectivityManager.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mNetworkStateListenerL = new ConnectivityManager.NetworkCallback() {