我正在尝试接收ACTION_DOWNLOAD_COMPLETE
请注意,下载由Chrome启动,然后由DownloadManger接管。
<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没有发送意图。