I'm developping an app that permits the user to listen some podcasts. The app is downloading content from a server such as descriptions, images and also stream from an URL an audio flow.
I'd like to implement a cache which would save all these podcast objects containing basic types (such as strings for the description for example) but also the image linked to the podcast and the podcast itself (audio flow).
If I had to compare this to any other app it would probably be the Soundcloud app which does all this.
I searched on the web to find some tutorials or good pratices but these are explaining the basic way to cache basic objects. Also I found Volley but this is bad for streaming audio or things like that.
If anyone could help, it would be great. Thanks.
If you want to cache them in memory use LruCache, if you want to cache them on disk use DiskLruCache. Check this Caching Bitmaps and this DiskLruCache.
Related
I just finished reading few some sparse tutorials on caching/offline and about making an Apps responsive when the user is not connected to the internet. It was quite interesting cause I have being wondering how some Apps have being doing that cause I was thinking it was some database manipulation.
I am relatively new to the caching mechanism and I really want to implement it in my next project cause I am still learning.
The few tutorials I have read talks about caching static files like pictures, .css files, .js files etc
My question is this;
**Question 1**
How do I cache Dynamic Files e.g I have an Apps when a User want to view their profile, I normally implement it by sending an Ajax request to the server to populate the profile page with pictures and other profile details (texts). How Do I cache these texts and pictures since they are dynamic?
**Question 2**
I am using different page (index.html, profile.html) JQuery Mobile mechanism, will this affect caching in any way because I have to refresh the page every time I am navigating to a new page so as to show my styling correctly?
This question may sound really noob but I really want to learn and I have read a lot about caching but these question were not addressed. I just hope somebody helps. thanks...
Answer is given based on my knowledge so far.
1) You can store / cache things with localStorage It's preety basic so won't take a lot of time or coding or mechanism to implement. Profile data, image as encoded string can be saved in localSorage. First you will save the profile data in localStorage. Then next time after app starts you can load data from the localStorage and also in the mean time you can make a async ajax call to server to check if data is modified. If so, then you can bring that data again and update localStorage.
2) If you use localStorage then page transitions won't be a matter until you reach the localStorage size limit of 5 mb.
I'm building a video player. I've thousands of video files stored in both internal and external storage. So my video listview is very long and take time to load. my listview contains an imageview and a text view. I can cache the thumbnails, but don't know what to do with the list.. any idea???
Be simple...
don't make every thing dynamic, unless it would be a critical thing.
Use sqllite, txt file or xml to store the lists of names, pathes ... etc.
It will increase the performance dramatically.
Best
You should not load all the contents at the same time. use a LRUcache to store a few thumbnails and add/delete one element each time you need a new image. Simply show a progress dialog before loading success. Refer this for usage of LruCache.
You can refresh the image data in getView method
Try this this can be helpful for you
Use MediaStore and ListAdapter. MediaStore is already managing thumbnails and filesystem paths for all media types (photo, video and audio).
Here's an article covering the basics of content providers, aka databases, which is what MediaStore is.
Here's an example of querying MediaStore for videos.
Also, this stackoverflow question seems similar to what you're doing.
One more thing: if you need to load media over the network (instead of local filesystem) then use the ContentProvider+Service technique described by Virgil Dobjanschi in his talk from Google I/O 2010 (video,pdf). At first it will seeem like overkill but the upfront work will pay repeated dividends in performance, avoiding caching bugs and avoiding rework.
Hello sages of the Overflowing Stack, Android noob here..
I'm using CSipSimple and want to stream the call audio to another app, in chunks of 1 second audio data so that it can process the raw pcm data.
The code that handles the audio in CSipSimple is native, so I prefer using native approaches and not callback Java.
I thought of a few ways of doing so:
Use audio streaming and let the other app get it.
Writing the data to a file and let the other app read it.
Calling a service in the other application (AIDL)
Using intents.
These are the considerations leading to my dillema:
Streaming looks like the natural choice, but I couldn't find Android support for retrieving raw pcm data from an an audio stream. The intent mechanism is flexible and convenient, but I don't think that that's what they're meant for. Using a file seems cumbersome, although it's well supported. Finally, using a service seems like a good option but it seems less flexible and probably needs more error handling and thread management.
Can you guys point out the best alternative?
If you have another one you're welcome to share it..
I do not know about the streaming audio API support so I'll not touch this case.
As for writing data to a file and let other application to read it - this is a possible case how to solve your problem.
As for calling service through AIDL and using intents, I do not think that this is a good solution. The problem is that Binder has a limitation over the size of the data (1MB) that can be passed in a transaction.
To my point of view, the best solution (especially if you're working in native) is to use AshMem. This is a shared memory driver developed specifically for Android. Thus, in your service you create a shared memory region and pass the reference to it into your client app that reads information from the this memory.
I am working on an android app for my church and would like to put our sermons on it. The company we upload our sermons to automatically makes a podcast feed for it. Basically I am looking for a way to list podcasts inside of the app. I would like it to be hardcoded to one podcast. I have looked online but cannot really find anything about. I am not sure how to code the podcast part. More than likely the actual playing can be handed off to a secondary app.
there two steps i recommend.
A) Use the Aquery lib to parse the xml or json returned by the podcast feed link.
Check it out https://code.google.com/p/android-query/. Doesnt matter what layout you use to display the podcast items.
B) Then you can Streaming the audio from A URL using MediaPlayer. http://www.tutorialspoint.com/android/android_mediaplayer.htm
Good luck
I am managing a bunch of PDF files in an android application maintaining a list of records in a SQLite database as well as storing the pdf files on the external storage.
Now I would like to present a thumbnail of the first page of the pdf in my list view as part of each cell representing a pdf.
I am aware of libraries like iText, fop.. on the JavaSE side that can render a PDF but I would rather not delve into embedding a large library like that. On a similar approach I would also rather not embed a native PDF viewer like droidreader, apv or vudroid.
Otherwise I could of course also get it rendered on a server via some webservice but that is a lot of headache as well.
I am already using intents to get the pdf's displayed for the user so I was thinking it would be great if I could get a thumbnail via a intent call as a result somehow. However I found nothing on the web (e.g. on openintents) that indicates something like that exists ..
So I am a bit at a loss on what to do? What do you think is the best approach to get these thumbnails into my app? Are there any public intents available? Or did I just totally miss something and the SDK provides features for that already (it should imho but currently does not)?
You are going to get a lot faster resopnse rasterizing the PDFs on the server and there are lots of libraries to do this in C, Java, Php.