diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d1308f..8735df9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### Fixed - Fixed duplicate call for onProgress +## [1.2.2-dev.1] - 08-04-2024 +### Fixed +- Fixed binding a broadcast in new android 14 issue + ## [1.2.1] - 07-01-2024 ### Fixed - Fixed crash exception when file URL does not contain file extension diff --git a/README.md b/README.md index 174934b..e76b0b0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ First, make sure that you've added the permissions to your AndroidManifest.xml ``` Add the following line to your pubspec.yaml -``` flutter_file_downloader: ^1.2.1``` +``` flutter_file_downloader: ^1.2.2-dev.1``` Next, add the library import to your dart file, diff --git a/android/src/main/java/com/odehbros/flutter_file_downloader/FlutterFileDownloaderPlugin.java b/android/src/main/java/com/odehbros/flutter_file_downloader/FlutterFileDownloaderPlugin.java index fb7c884..7643df3 100644 --- a/android/src/main/java/com/odehbros/flutter_file_downloader/FlutterFileDownloaderPlugin.java +++ b/android/src/main/java/com/odehbros/flutter_file_downloader/FlutterFileDownloaderPlugin.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.Build; import android.content.ServiceConnection; import android.os.IBinder; @@ -31,9 +32,12 @@ public class FlutterFileDownloaderPlugin implements FlutterPlugin, ActivityAware private static final String TAG = "FlutterFileDownloader"; private final PermissionManager permissionManager; - @Nullable private MethodCallHandlerImpl methodCallHandler; - @Nullable private ActivityPluginBinding pluginBinding; - @Nullable private DownloadCompleterBroadcast onDownloadCompleted; + @Nullable + private MethodCallHandlerImpl methodCallHandler; + @Nullable + private ActivityPluginBinding pluginBinding; + @Nullable + private DownloadCompleterBroadcast onDownloadCompleted; public FlutterFileDownloaderPlugin() { permissionManager = new PermissionManager(); @@ -98,7 +102,12 @@ private void deregisterListeners() { } private void bindForegroundService(Context context) { - context.registerReceiver(onDownloadCompleted, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + final IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); + if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) { + context.registerReceiver(onDownloadCompleted, filter, Context.RECEIVER_EXPORTED); + } else { + context.registerReceiver(onDownloadCompleted, filter); + } } private void unbindForegroundService(Context context) { diff --git a/pubspec.yaml b/pubspec.yaml index 78244b0..06ddf20 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_file_downloader description: A simple flutter plugin that downloads any file type to downloads directory -version: 1.2.1 +version: 1.2.2-dev.1 issue_tracker: https://github.com/abdallah-odeh/flutter_files_downloader/issues homepage: https://github.com/abdallah-odeh/flutter_files_downloader