安卓下载管理器 [英] Android: Download Manager

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

问题描述

我要实现我想要的应用程序的下载后搭上 android.intent.action.DOWNLOAD_COMPLETED 从Android Market应用程序,即意图的解决方案。 Android市场的应用程序使用默认的下载管理器和下载完成的下载管理器发送这样的意图,但我一直没能捕捉到它,我也跟着的本教程并请参照<一个href="http://www.netmite.com/android/mydroid/donut/packages/providers/DownloadProvider/docs/#ContentProvider_for_download_UI"相对=nofollow>这来就如何市场的应用程序使用的下载管理器以及有关下载管理器的更多信息,请参阅的这个。请不要给我建议的方式来捕捉那些意图。

修改 这是我使用了我的广播Reciever

什么

 &LT;使用-权限的Andr​​oid:名称=android.permission.ACCESS_DOWNLOAD_MANAGER&GT;
&LT; /使用-许可&GT;


&lt;应用机器人:图标=@可绘制/图标机器人:标签=@字符串/ APP_NAME&GT;
    &LT;接收器
        机器人:名称=。DownloadReceiver
        机器人:权限=android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS
        机器人:出口=真正的&GT;

         &LT;意向滤光器&gt;
            &lt;作用
                机器人:名称=android.intent.action.DOWNLOAD_COMPLETED&GT;
            &LT; /作用&gt;
         &所述; /意图滤光器&gt;
     &LT; /接收器&GT;
  &LT; /用途&gt;
 

解决方案

您已经得到了一切权利,除非在意图过滤器的操作的名称。注意 DOWNLOAD_COMPLETE 而不是 DOWNLOAD_COMPLETED

 &LT;接收器
        机器人:名称=。DownloadReceiver
        机器人:出口=真
        机器人:图标=@可绘制/ download_icon&GT;
        &LT;意向滤光器&gt;
            &lt;作用机器人:名称=android.intent.action.DOWNLOAD_COMPLETE/&GT;
         &所述; /意图滤光器&gt;
     &LT; /接收器&GT;
 

这为我工作。你并不需要注册在code接收器,这会听,即使你的应用程序没有运行。

I want to implement a solution where I want to catch the android.intent.action.DOWNLOAD_COMPLETED intents from the Android Market App i.e after the download of the app. The android Market app uses the default Download Manager and the download manager on the completion of the download sends such an intent, however I have not been able to capture it,I followed this tutorial and please refer to this to have more details on how market app uses Download Manager and for more information on Download Manager refer to this. Please do suggest me a way to catch those intents.

EDIT This is what I am using for my Broadcast Reciever

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


<application android:icon="@drawable/icon" android:label="@string/app_name">
    <receiver 
        android:name=".DownloadReceiver"
        android:permission="android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS"
        android:exported="true">

         <intent-filter>
            <action
                android:name="android.intent.action.DOWNLOAD_COMPLETED">
            </action>
         </intent-filter>
     </receiver>
  </application>

解决方案

You've got everything right except the name of the action in the intent filter. Note the DOWNLOAD_COMPLETE instead of DOWNLOAD_COMPLETED

    <receiver 
        android:name=".DownloadReceiver"
        android:exported="true"
        android:icon="@drawable/download_icon" >
        <intent-filter>
            <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
         </intent-filter>
     </receiver>        

This worked for me. You do not need to register the receiver in code, this will listen even when your app isn't running.

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

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