I am new to Android and I am currently working on a project that requires a lot of Http requests on a web API.
I have been searching for good practices about refactoring AsyncTask subclasses, so I don't have to write a lot of similar code into each Activity class.
Do you have any tips/advices or even an example of how you proceed ?
Thank you.
I think what you are talking about is already answered here In this answer it has a same topic's discussion, Although i also know some blogs that can help you to make it more conceptually clear read them,
Links:
https://trinitytuts.com/reusable-asynctasks-class-in-android/
http://cyriltata.blogspot.in/2013/10/android-re-using-asynctask-class-across.html
Related
Recently I am working on Android app development, and also I did iOS app before. I am not good at Android so far, so sometimes I found the app is kind lagging, thought stackoverflow.com is very nice place to share and found the bug, but I would like to ask if there are some websites that I can share all codes and details about the app, and there are also some programmers there they can read and point it out what's wrong with my app? I don't know if this question is legal here, just think it's good to have one and learn more..
You can post code and get it reviewed at https://codereview.stackexchange.com/
The best solution would probably be to push your projects to a site like Github where there's a great infrastructure in place to allow people to collaborate with you.
Asking people to do so is a different issue, but probably best achieved through posts on XDA-developers and equivalent forums.
There are plenty of places where you can post your entire source code. Here are two that I have used:
Google Code: allows you to post your code publicly with details about downloading. You can use this and google forumns to get reviewed and help. SVN access is easy to configure. Can add others to projects.
SourceForge: allows you to post code publicly and privately. SVN is easy once again. Allows you to add others users to the project with read/write/edit permissions.
Those two may not be the best places for getting reviewed and help easily, but they are wonderful for hosting and source control!
Also, these do have forumns where you can point others to your projects and ask questions!
I am trying to make a client with asynchronous. I am not good in Java. Then its a bit difficult for me. I want to recieve and send data as much as performance.. And I think Asynchronous is the best option for it? I wanted to use cometd but its more complicated.. anyway What can I do for it? or Which way I should follow?
Thank you
Take a look into AsyncTask. There are various ways to do work on separate threads. See here.
provide any related links.
If yes it's fine. If NO why? suggest me.
Not sure what exactly you mean. SOAP UI itself is a windows application. Android of course can communicate with a server using SOAP messages.
I don't want to be rude, but spending a bit more time on the question would help others to be motivated to answer as well make it easier to find the answer you are looking for.
I am searching for a solution to update the UI from a service.
The best solution I found is this one:
subclass Application and let in-app
communication go through this class
As suggested here More efficient way of updating UI from Service than intents?.
Unfortunately I am new to Android and Java programming, so I do not really understand how this works.
It would help me very much, if someone could create a working example project from the given code snippets in the solution. An app that starts a service, increases a counter and displays the counter in textview would be a good and simple example. I think I will understand this much better than a therotical solution.
Here is an answer to a similar question where there is a full example. If you are just doing some basic background task, an AsyncTask may be a better solution though.
It would be nice if StackOverflow had a section where we could post tutorials like mine so that I can answer literally hundreds of questions that have been asked here with a single blow. See... every day I read questions about how to pass complex objects between activities, how to save state so that your app can resume after orientation change, how to update listviews when the data changes, etc, etc.
Here is the second part of a tutorial series I posted on my blog... I hope that you actually read it... because I haven't seen any examples like it anywhere... and it has changed how I think about developing for Android across the board. The question is... is there a downside or negative affect of developing like this?
Beyond Smart Lists – How Observable Singletons change the game.
Please read through both of these tutorials carefully... I will answer any questions about it here that I can... I really want to know what you think about this and if it might solve issues for you.
NOTE TO MODERATORS: there are no advertisements of any kind on my blog.. so don't just close this because you think I am spamming somehow... I am not going to duplicate my post here. And... really I want to know if there is a flaw in this approach.
Have you read about Android's Application class?
Application's javadoc
sharing-domain-objects-between-activities.