Android: Download Manager

后端 未结 3 543
我在风中等你
我在风中等你 2021-01-14 21:48

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

相关标签:
3条回答
  • 2021-01-14 22:16

    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.

    0 讨论(0)
  • 2021-01-14 22:25

    First register the reciever

    registerReceiver(onComplete, 
    new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    

    And set a BroadcastReciever to capture the event.

    BroadcastReceiver onComplete=new BroadcastReceiver() {
            public void onReceive(Context ctxt, Intent intent) {
                // run your action here
            }
        };
    
    0 讨论(0)
  • 2021-01-14 22:31

    Probabily your receiver is declared with lower priority than the registered for the Market application. Try to use IntentFilter.setPriority() or declare the priority on XML here

    0 讨论(0)
提交回复
热议问题