From 2eec3de87b6b616a69a46c1f97c2397159031d2f Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 21 十一月 2023 18:01:43 +0800 Subject: [PATCH] 广告升级/bug修复 --- library-DownloadProvider/src/com/mozillaonline/providers/downloads/DownloadReceiver.java | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/library-DownloadProvider/src/com/mozillaonline/providers/downloads/DownloadReceiver.java b/library-DownloadProvider/src/com/mozillaonline/providers/downloads/DownloadReceiver.java index 526fc6b..9d6027c 100644 --- a/library-DownloadProvider/src/com/mozillaonline/providers/downloads/DownloadReceiver.java +++ b/library-DownloadProvider/src/com/mozillaonline/providers/downloads/DownloadReceiver.java @@ -30,6 +30,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; +import android.os.Build; import android.util.Log; /** @@ -46,7 +47,8 @@ String action = intent.getAction(); /*if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { startService(context); - } else */if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + } else */ + if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if (info != null && info.isConnected()) { @@ -101,7 +103,8 @@ /** * Hide a system notification for a download. - * @param uri URI to update the download + * + * @param uri URI to update the download * @param cursor Cursor for reading the download's fields */ private void hideNotification(Context context, Uri uri, Cursor cursor) { @@ -128,7 +131,7 @@ private void openDownload(Context context, Cursor cursor) { String filename = cursor.getString(cursor.getColumnIndexOrThrow(Downloads._DATA)); String mimetype = - cursor.getString(cursor.getColumnIndexOrThrow(Downloads.COLUMN_MIME_TYPE)); + cursor.getString(cursor.getColumnIndexOrThrow(Downloads.COLUMN_MIME_TYPE)); Uri path = Uri.parse(filename); // If there is no scheme, then it must be a file if (path.getScheme() == null) { @@ -147,6 +150,7 @@ /** * Notify the owner of a running download that its notification was clicked. + * * @param intent the broadcast intent sent by the notification manager * @param cursor Cursor for reading the download's fields */ @@ -185,6 +189,11 @@ } private void startService(Context context) { - context.startService(new Intent(context, DownloadService.class)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + context.startForegroundService(new Intent(context, DownloadService.class)); + } else { + context.startService(new Intent(context, DownloadService.class)); + } + } } -- Gitblit v1.8.0