开发者

How do you force android to download a podcast instead of playing it?

I'm trying to find a way to bypass the selection pop-up for podcasts and just tell android to download the file.

Currently when you open a link to a podcast a little menu pops up and has two buttons. One says download, and one says listen. Instead I want "Download" or "Cancel".

I have looked into this and I found the DownloadManager class, but sadly (I think) it is only for 2.3, and the app is being developed for 2.2.

Does anyone know how android did file downloading before this? Is there a s开发者_运维知识库pecific intent I can pass the link to?

Thanks!


Well, without code I can only guess.

It sounds as if you have a Web View or Browser that is interpreting the url being opened based on part of the url scheme. This is causing the operating system to try to resolve activities that are available for this url. You're seeing two activities (download or listen) which are supported by activities available on the phone. In this situation you will need to overload the loading of urls using this tutorial,

Of course, without some crystal ball I can't be certain of this based on what you've said. If this is the case and you want to know how to download it. You would need to build a downloader of your own, which is possible using Java Streams, Java NIO or some of the Apache HTTP Client libraries. Based on the size of your files, it may make sense to use Buffered Java Streams with the Apache Http Client objects.

You can find an example of how to do this here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜