Search code examples
androidandroid-download-manager

Android Download Manager class name issue on Samsung S6


My app downloads pdf files from links on button click. I am using download manager and it is working great on ALL DEVICES except Samsung S6!

Here is a sample code

private boolean isDownloadManagerAvailable() {
try {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList");
    List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
} catch (Exception e) {
    return false;
}
}

Samsung S6 debugging shows that list.size() is actually 0 (ONLY ON S6). And i cannot find any alternative for the classes I am using, as all other devices work perfectly. I do not know if samsung has changed the classes in S6?!

Thanks.


Solution

  • I figured it out. Turns out samsung S6 does not have these classes and thus is returning 0. Returning true and ignoring this check did the job. The application i was updating was many years old code. I guess no need for the check anymore.