flutter_downloader icon indicating copy to clipboard operation
flutter_downloader copied to clipboard

File download no response.

Open liudonghua123 opened this issue 4 years ago • 6 comments

I followed the instructions on https://pub.dev/packages/flutter_downloader#-readme-tab- and https://github.com/fluttercommunity/flutter_downloader/blob/master/example/lib/main.dart, installed flutter_downloader: ^1.4.1, modified android\app\src\main\AndroidManifest.xml as the following.

android\app\src\main\AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.jeecgboot_app">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="jeecgboot_app"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <provider
            android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
            android:authorities="${applicationId}.flutter_downloader.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>
        <provider
            android:name="androidx.work.impl.WorkManagerInitializer"
            android:authorities="${applicationId}.workmanager-init"
            android:enabled="false"
            android:exported="false" />
        <provider
            android:name="vn.hunghd.flutterdownloader.FlutterDownloaderInitializer"
            android:authorities="${applicationId}.flutter-downloader-init"
            android:exported="false">
            <!-- changes this number to configure the maximum number of concurrent tasks -->
            <meta-data
                android:name="vn.hunghd.flutterdownloader.MAX_CONCURRENT_TASKS"
                android:value="5" />
        </provider>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
</manifest>

modified main.dart like the following.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await FlutterDownloader.initialize();

  runApp(new MyApp());
}

And In a onPress callback I wrote code like the following.

            onPressed: () async {
              // Downloader.download(fileUrl, fileName, '.$fileType');
              var _saveDir = await _findLocalPath(context);
              final taskId = await FlutterDownloader.enqueue(
                url: fileUrl,
                savedDir: _saveDir,
                showNotification:
                    true, // show download progress in status bar (for Android)
                openFileFromNotification:
                    true, // click on notification to open downloaded file (for Android)
              );
              print('_saveDir: $_saveDir, taskId: $taskId');
              final tasks = await FlutterDownloader.loadTasks();
              print('tasks: $tasks');
              Navigator.of(context).pop();
            },

However no error info printed, from the debug console log, I can only see the DownloadTask is always enqueue status, I have tried almost everything I can, but it seems the same result, no notification, no other log info.

I/flutter ( 6509): Download task is enqueued with id(d8463edf-ca00-42f4-8b89-417bc8157f93)
I/flutter ( 6509): _saveDir: /storage/emulated/0/Android/data/com.example.jeecgboot_app/files/Download, taskId: d8463edf-ca00-42f4-8b89-417bc8157f93
I/flutter ( 6509): tasks: [DownloadTask(taskId: 3ca10fa1-41b4-4296-b521-93fc6626f789, status: DownloadTaskStatus(1), progress: 0, url: http://192.168.1.96:3000/jeecg-boot/sys/common/static/mementopython3-english_1583207294984.pdf, filename: null, savedDir: /storage/emulated/0/Android/data/com.example.jeecgboot_app/files/Download), DownloadTask(taskId: d8463edf-ca00-42f4-8b89-417bc8157f93, status: DownloadTaskStatus(1), progress: 0, url: http://192.168.1.96:3000/jeecg-boot/sys/common/static/IPAccessHandler-fix_1583205752923.txt, filename: null, savedDir: /storage/emulated/0/Android/data/com.example.jeecgboot_app/files/Download)]

liudonghua123 avatar Mar 03 '20 04:03 liudonghua123

I also tried the latest example app, but after I clicked the download icon, no response later.

image

liudonghua123 avatar Mar 03 '20 05:03 liudonghua123

any luck ? facing the same issue!

AbanoubNassem avatar Mar 13 '20 17:03 AbanoubNassem

iOS HTTP status code: 0

image

When I set a breakpoint in 594 to stop the program: image Then continue program execution: image

But still failed. image

sunkaigoon avatar May 25 '20 03:05 sunkaigoon

#129

hanerx avatar Nov 22 '20 09:11 hanerx

Closing because of lack of activity.

bartekpacia avatar Sep 09 '22 17:09 bartekpacia

Any update on this? Facing same issue.

aanantt avatar Sep 10 '22 14:09 aanantt