I have a scenario which I think is pretty common in Android applications. I know partial attempts of solving the issue were made, but until now I have not stumbled upon the full implementation. I intend to try to implement such component and open source it afterwards, but I need your help in its design.
So basically my case is the following: I have list view showing image loaded from the web and text per each row. I want to lazily load the images, placing default for each image and substituting it with the real one only when the image is downloaded. I also want to keep image cache avoiding the need to download the images multiple times in short period.
Up to now I have found several implementations that are partially working including:
Tom van Zummeren's implementation of similar component with several well known problems
Jeremy Wadsack's refinement of the concept, which is more or less working
Lazy drawables source forge project.
I also saw several stackoverflow questions regarding the problem: 1, 2, 3
However I have one more requirement which makes my task a bit more complex: I allow the user of my application to affiliate himself with some of the images. I want to load the new images associated to the user whenever the user navigates to the home screen. From it he should be able to go see his images, even before they have all been downloaded and in this case again default placeholders should be visible (Note the cross screen transition). Such use cases are:
An app listing user's youtube videos
An app for facebook - consider the images of friends
An app serving news that supports user's favorites etc
Note that I want to start fetching the new data related to the user on the home screen to provide better user experience. I will keep the user-related data stored locally forever.
The question
So my basic question is what approach should I use for the implementation of the image downloading? I know that the Android manuals say Service should be used only when I want to execute task even when application is not running. On the other side I will start the image downloading on the home screen and link the downloads to UI elements just when the user navigates to the new screen (Activity) - user-related list view and I do not know how to achieve that with AsyncTask (not that I have a very precise idea how to do it with Service either).
Any suggestion will be greatly appreciated, including links.
Universal Image Downloader is a good library which helps you to do image downloading in background with your settings.
It has so many features that you can implement at your own way.
Related
I am thinking about creating a text-based game (similar to gamebooks) for android device. In this moment only theoretically. Do you have some advice please, which way to go?
You probably know how gamebooks works, but the gamebook I want, will be very easy, should work like this:
User has shown some image, text and 3 options (questions), he decides which option to click, then a new page is showing (according to the clicked option) with another image, text and another 3 options. Then again, the user clicks one option, another page opens, etc.
My question is not how to do it programmatically, but how to start with this in Android Studio, what system to use for such game on android or which way to go.
Because I think it has no sense to create intents after each click, as there might be hundreds of clickable options.
I have already created such game on my website with php/html/js, but I want to create it also offline for android.
Intents implies one activity per page - unmaintainable.
You should work with a database and load based on user interaction. So you'll need to learn about Databases and Asynchronicity (working in the background while updating the UI so the user knows)
For some unfathomable reason Google decided to add Splash Screens (Launch Screen) to their design guidelines, I know that,
1. Splash screen is better than staring at an empty screen.
................ [ Inflating the main layout and showing a UI without any dynamic data should be very fast. If that's not the case in your app you should fix it by making it fast to load instead of adding a splash screen that will then guarantee that your app is always launching slow.]
2. Splash screen is better than not having any information if the app is launching other than the launcher button getting pressed.
3.app's data takes a long time to load. A splash screen is better than a loading indicator. This especially with slow internet speeds.
All these problems , But splash Screen Is not only Single solution I think, It also have some Cons Like:
If you show your app's UI to the user first and then load the data into it you allow user to orient to the UI and they're immediately ready to go when the data comes in.
Users don't always want to interact with the data on the app's landing screen. Let the user get on with their task without forcing them to load the first screen's data. This is very important especially on a slow internet connection. Let user interact with your app while the data is loading. In many cases they might not care about the data you're loading by default.
********** Friends,I am using **UBER App & even only I want to see my "Promo code" To share with friend I need to Open app & Its take lots of time to open and for that much time I stuck on Splash screen & If there is no internet connection then app Stuck on startup I can't even read my "Promo Code"
So, My question is that , can we avoid splash screen there is another alternative? Its really needed & useful? Why cant we think about any other innovative Concept?
Sanket, splash screens also allow for the app itself to load. some apps like facebook are not actually apps but the normal website for mobile phones... made into its own special browser for only that website. thus, the app itself must load even its menus, which have icons and all on them. splash screens definitely would be great for those apps, though, other apps such as a non-website app..IE, something that loads locally then connects to the internet to update and cache data would totally be usable without a splash screen. you could straight up display or open the app to a menu and show a loading wheel on the menu options that aren't fully loaded yet. instead of a splash screen, you could also show terms and conditions of your app so users can go ahead and agree to them if they are required (such as apps that require use of an online service.)
Just display a dialog about you app updates or If ur app contains login functionality just use login using dialog.I think it may be an best alternative for splash.
So i got a lot of solutions online but none of them were simple and complete. First i tried using imageview and adding external libraries for zooming etc. but i couldn't find one which had all the functionality we see in a gallery app without being extremely slow. I read something about canvas though don't know what it is. I also found "zooming a view" in android official tutorial but it was just a single tap zoom. So which is the best solution (in terms of functionality and speed) for this: I want an activity to show just a single image such that the user can zoom/rotate/pan it as its gonna contain text that the user needs to be able to read. So basically just like a gallery app. Is it possible to call on the gallery app activity to display this image? Why doesnt android have better support to do this? What is the best way you would suggest.
Hello guys (and girls),
I need your help in the matter of how to structure things in an Android app that I'm developing.
So far I have:
a Login activity that shows up right after the app is started
a Main activity that display some options for the user. Among them there is an option to start the device's camera (user taps on an icon that should launch the Camera), take a picture, crop it / rotate it and upload it to a remote server
Now, my question is: how should I organize things in my app logic so that everything will be clear and easy to manage in the future, for the upcoming versions?
I'm thinking like this but I'm not sure if it is the right way:
create a separate activity (eg. PictureCaptureActivity) for the picture capture task
create a separate activity (eg. PictureProcessActivity) for the picture processing tasks (crop and / or rotate - these options will be available via some buttons displayed on screen, in the main menu bar)
create a separate activity (eg. PictureUploadActivity) for the picture upload tasks
Or should I include all these functionality in my MainActivity somehow? Or... ?
Thank you in advance for your guidelines!
Before i start referring you to well written documentation and examples i have one main point i would like to emphasis and convey.
You are referring to Activities where modern Android applications are compartmentalized by Fragments (not that modern, almost 3 years) and the point of that being that the same application can work by utilizing almost 100% of the code on all Android* devices and form factors (mobile, tablet, TV, wear, auto etc.).
Now lets talk business, the best place to start reading on regarding Android is Google:
Design/patterns/application structure - from the android.developers.com documentation site.
Application quality checklist - created by Google following hundreds of case studies and a meticulously planned UX test.
Design guidelines - updated just 2 days ago (16.4.15).
IOSched - Google's display window for Android code where they show how they think an Application should look, feel and behave.
After that i would love to link you to a code lab i co-wrote with a couple of friends and a few blog posts i have written as a follow-up:
AndConLab
My tech blog on Android
Goodluck.
PictureCaptureActivity
Do you want to have a custom interface for taking pictures with the camera, or use an existing application on the phone?
Yes - You will need a PictureCaptureActivity and will have to implement the camera functionality yourself.
No - You can use an Intent to get the user to take a picture using another application and return it to you.
Either way, you will need to look at the Camera documentation.
PictureProcessActivity
You will most likely need to have a PictureProcessActivity to process the pictures in the manner you want.
PictureUploadActivity
The PictureUploadActivity is not really necessary. You could use a Progress Dialog or Progress Bar to show the progress in the PictureProcessActivity.
MainActivity
In my opinion you need at least two activities:
MainActivity / PictureCaptureActivity to take a photo
PictureProcessActivity to process the photo
You could fit it all into one activity by hiding and showing icons in the Action Bar, but I'd rather not because the Activity Documentation states:
An activity is a single, focused thing that the user can do.
Disclaimer: There is no 100% correct way to do this.
I've found this to be very helpful when it comes to code keeping: https://google-styleguide.googlecode.com/svn/trunk/javaguide.html
The one thing I can't stress enough: comment your code
I'm working on android application that will have basic image gallery functionality included. I've managed to build activity that fetches list of photos from my application backend API and render them in android gridview within activity layout.
This is how it looks like at the moment:
However I'm having difficulties to build same gallery experience for user's device photos that were taken by camera and stored on device. Two solutions I considered were:
Building my own image gallery.
Starting default android image gallery using intent.
Solution 1: I belive that first solution will take me too much time to developed. I started with this tutorial but as soon I implemented it I found out that it is running too slow. Then I take a look at android camera source code to find solution but again I found that it will take me too much time to review the code and to build my own gallery from scratch. I also believe that it is not in Android OS philosophy to rewrite functionalities that already exists but to use Intents to start activities that can handle actions you need. This lead me to second solution.
Solution 2: I tried calling default android gallery using intent in order to browse user's device photos by soon I was stuck again. Problem this time was that as soon as user tap on photo, gallery exits and returns to activity that originaly started it, and I expected (and I want) to start large image preview instead. I saw that others had this problem too how to open gallery via intent without result.
Because I didn't find the fix for this I decided to quit.
My question is how can I overcome these problems and build gallery that is similar to one I already have for web photos.
If anyone could give me reference I would be most thankful.
this question is pretty old but, as it has a lot of views and quite a lot of upvotes, it could be good to bring an answer to it.
So, first the tutorials evolved a bit and you can find some cool stuff for your #1 option:
This is the one I prefer
This one uses a deprecated UI element but is also cool
This uses an Adapter which is, to me, the best way to proceed.
For your #2 option, I do not see any idea to not to return to the original activity because you still do not have control over the result of the intent you send through the system.
But there are another solution that you didn't mention: there are librairies which are very cool and that you could customise to get exactly what you want:
This one is a bit fancy
This one seems also to be pretty cool but you could have problems importing it because it's not a gradle project
This is the one I would definitely use.