无法接收广播意图ACTION_DOWNLOAD_COMPLETE

时间:2018-04-20 01:47:01

标签: android android-intent android-broadcastreceiver

我正在尝试接收ACTION_DOWNLOAD_COMPLETE
请注意,下载由Chrome启动,然后由DownloadManger接管。

<小时/> 这是我的相关manifest.xml

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" /> 
<application>
    <receiver
        android:name=".receivers.DownloadBroadcastReceiver"
        android:directBootAware="true"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
        </intent-filter>
    </receiver>
</application>

<小时/> 这是DownloadBroadcastReceiver

public class DownloadBroadcastReceiver extends BroadcastReceiver {
 @Override
 public void onReceive(Context context, Intent intent) {
     Log.i("TAG", "onReceive: A download happened");
 }
}

编辑:我尝试使用adb发送意图

  

adb -d shell am broadcast -a android.intent.action.DOWNLOAD_COMPLETE

然后我的应用程序响应,看起来像DownloadMangeris没有发送意图。

0 个答案:

没有答案