Skip to content

Commit

Permalink
Merge pull request #45 from abdallah-odeh/hot-fix
Browse files Browse the repository at this point in the history
Fixed binding a broadcast in new android 14 issue
  • Loading branch information
abdallah-odeh authored Apr 11, 2024
2 parents 6db6816 + 34baf4c commit f650b97
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit f650b97

Please sign in to comment.