Android Client with Asynchronous Way - android

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.

Related

How to make a generic AsyncTask?

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

Android: Separation of Rest API calling code, inside AsyncTask or separate?

I wondering if anyone can offer some suggestions on where I should be putting API Rest calling code. I of course could put this in every single AsyncTask that I am using. Which works but it doesn't make it very usable.
The other way I thought was creating an ApiConsumer class that would have all the rest calls list "getList()", "getExpiredItems()", "deleteItem(int id)" etc.
I though this would be ideal so they would be able to be used from everywhere. Inside these methods I am still using HttpUrlConnection to make network calls so I would still need an AsyncTask but instead of implementing the HttpUrlConnection stuff inside the AsyncTask then I would call the "ApiConsumer" methods that I setup before.
In my mind this seems a logical way of going, is it?
Am I trying to do something that has already has a different solution?
Anyone know of any articles or examples outlining similar solutions as I can't seem to find one.
I know placing HttpUrlConnection code directly inside the AsyncTask is ok, but I just don't see it very reusable and wanted to abstract it out.
Retrofit is something you should look at, it pretty easy to integrate, will save lots of development time.
Easy syntax,Support annotations
In built GSON deserializer
Customizable according to your needs
Content format Agnostic
Lots of devs are using it, so you will get good support over web
Volley & AsyncHttp are also good alternatives, you will find plenty of such libraries.
P.S: I am using retrofit for most of my projects

Android application interacting with a server

Ok so, I know the question is pretty much google-able and I did google it and found out a few answers ,so I am not asking this question knowing completly nothing.
So, I have an application (Cannot specify much about what it does or is or so...) and I need to get some data from a database.
As far as I know, the Volley is the best way to go ,but I am still looking for more details.
Could anyone tell me which is the best way to go?
NOTE: I am NOT looking for code,I am looking for methods.A name would sufice ,as I can do the digging myself.Eventually links to documentations would be awesome, but again, I can find documentations.I just need to know which is the fastest way and the most optimized.
Based on your comment, it looks like there are two different aspects to your application:
Sending out the HTTP requests from your client- i.e. your android app
Processing and sending the response to these requests on the server side, by setting up a web service
Looks like you have part 1 figured out. Note that, volley is a library, similar to android HTTP library, but optimized for faster networking.
For part 2, unless you're planning to use embedded database like sqlite, you'd need to learn about writing web services to provide database access.
Spring Data JPA is one of the many ways to do it.
I hear Parse is great too, but not free.

Can we communicate client and server using SOAP UI in Android?

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.

How to let a thread communicate with another activity thread

i'm beginning to learn android, i meet a problem in my project,
in my application,i create a background thread which get data from remote server by UDP,
in this thread ,i will parse the data and distribute the message to different activity to process, so i don't know weather is there a mechanism to handle this problem.
thanks for your answer
You should take a look at this article about painless threading in android, and pick a solution that best fits for you.
If you retrieve data from the server repeatedly, maybe you should go with a Service - Handler solution, but AsyncTask seams to be the easiest for me.
I would recommend you to go through the dev guide as suggested by #UBM. Also, if you are looking for different threading constructs and communication, I would strongly recommend you to look at a series of articles on Android threading constructs starting with this article.

Categories

Resources