fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
905 stars 508 forks source link

Downloading not Starting on OPPO with android 11 #963

Open SherazAsghar37 opened 2 months ago

SherazAsghar37 commented 2 months ago

I've been debugging it for a day but the issue persists, when I start downloading it prints "set process for client: com.example.igb" and nothing happens. I've tested it on several Android 11 phones such as One Plus and it worked fine, but on Oppo, it didn't.

My AndroidManifest.xml: <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.igb"

<application android:label="igb" android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:taskAffinity="" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" android:requestLegacyExternalStorage="true">

<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />

<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 android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" android:exported="false" tools:node="merge"> <meta-data android:name="androidx.work.WorkManagerInitializer" android:value="androidx.startup" tools:node="remove" />

        <!-- declare customized Initializer -->
        <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="3" />
        </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>
<!-- Required to query activities that can process text, see:
     https://developer.android.com/training/package-visibility and
     https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

     In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
    <intent>
        <action android:name="android.intent.action.PROCESS_TEXT"/>
        <data android:mimeType="text/plain"/>
    </intent>
</queries>

My code:

@override void initState() { super.initState(); FeedbackController feedbackController = Provider.of(context, listen: false); IsolateNameServer.registerPortWithName( port.sendPort, "downloader_send_port"); port.listen((dynamic data) { printError("here"); String id = data[0];

  DownloadTaskStatus status = DownloadTaskStatus.values[data[1]];
  double progress = data[2] / 100;
  printWarning(
      "Received download update - id: $id, status: $status, progress: $progress%");
  feedbackController.updateStatus(id, status, progress);
  setState(() {});
});
FlutterDownloader.registerCallback(downloadCallback);

}

@override void dispose() { IsolateNameServer.removePortNameMapping("downloader_send_port"); super.dispose(); }

@pragma('vm:entry-point') static void downloadCallback(String id, int status, int progress) { // printWarning("Download callback - progress: $progress"); IsolateNameServer.lookupPortByName('downloader_send_port') ?.send([id, status, progress]); }

shrutgyan commented 2 months ago

Facing same issue on Android 10 also. Did you find any solution to this problem??