如何使Android的下载管理器 [英] How to Enable Android Download Manager

查看:1025
本文介绍了如何使Android的下载管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Android的下载管理器下载文件列表。最近,我遇到了一个崩溃报告称

I'm using Android Download Manager to download list of files. Lately I came across a crash report saying

未知java.lang.IllegalArgumentException:如果未知的URL内容://下载/ my_downloads

后来的后来,我想通了,其原因是因为用户禁用Android的下载管理器。我检查,如果下载管理器是通过检查它与下面的code包名称禁用。

Then later, I figured it out that the reason is because user disabled Android Download Manager. I check if the Download Manager is disabled by checking it's package name with the code below.

int state = this.getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads");

而现在,我需要找到一个方法,使下载管理器,如果它被禁用。我尝试设置它的使能状态,在清单的权限,但我不断收到安全异常。

And now, I need to find a way to enable the Download Manager if it is disabled. I tried setting it's enable state with the permission in Manifest but I keep getting Security Exception.

this.getPackageManager().setApplicationEnabledSetting("com.android.providers.downloads", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);

<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>

所以,我想这可能是不可到达的,因为它是一个系统的应用程序。 (谷歌Play应用做它)。

So I thought it might not be reachable because of it is a system app. (Google Play App does it).

有没有办法将用户重定向到下载管理器应用程序信息的看法?让用户能够呢?如果没有办法就启用它编程的运行时间。

Is there any way to redirect the user to the Download Manager Application Info view ? to let the user enables it ? If there is no way to enable it on run time programmatically.

推荐答案

有些人正在寻找一种回答这个问题,我只是意识到了这个问题做出回答是莫名其妙地删除。所以我想回答我的问题。

Some folks were looking for an answer to this question and I just realized that the Answer made to this question is somehow deleted. So I want to answer my own question.

有没有办法来激活/停用直接下载管理器,因为它的系统的应用,我们不能够访问它。

There is no way to activate/deactivate Download Manager directly, since it's system application and we don't have access to it.

唯一的选择左边是将用户重定向的下载管理器应用程序的信息页。

Only alternative left is to redirect the User to the Info Page of Download Manager Application.

try {
     //Open the specific App Info page:
     Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
     intent.setData(Uri.parse("package:" + "com.android.providers.downloads"));
     startActivity(intent);

} catch ( ActivityNotFoundException e ) {
     e.printStackTrace();

     //Open the generic Apps page:
     Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
     startActivity(intent);
}

这篇关于如何使Android的下载管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆