I have an Android app that fetches data from the web service using ksoap2, the web service in turn fetches that information from SQL Server and sends it to the app, ksoap2 is fast and reliable and I'm happy with it.
I'm about to add a new feature which is the app will fetch multiple images from the server too. I searched for the best way to do this and I landed on three options:
keep using ksoap2 and store the images on the SQL Server, the web service will send the images in binary strings and then the app with render them and display them.
Store the images on the hard drive and use HttpUrlConnection, the web service will send the images path (url) through ksoap2 and the app will use HttpUrlConnection to download the images and display them.
Use JSon
My question is, from your experience which way should I go for? or maybe you have a better solution than that?
Thanks.
I would use option #2:
Store the images on the hard drive and use HttpUrlConnection, the web service will send the images path (url) through ksoap2 and the app will use HttpUrlConnection to download the images and display them.
This gives you the benefits of ksoap2, without a hacky workaround trying to jam images into SQL binary strings.
Additionally (and this is without knowing anything about the app you are creating) it allows you to only load the images when you actually need them, saving bandwidth, battery and memory.
Related
I'm new to android, I'm trying to build an android app that is a front for a web portal. For example, Airbnb. They have a website, but they also have an android app that, using it's own layout, will show listings from their website.
There are many websites that teach how to or even directly convert your website to android apps. However, this will result in an app that loads too slowly and is unresponsive due to CPU usage.
Could anyone share any tutorial/guide to learn how to do this myself?
Million thanks.
To actually load data from a web server you're gonna need and API which usually delivers the proper date using JSON or XML format so that you can properly parse and display that data. Building this API is in it self a complete course on its own.
But connecting to and requesting data from the API is usually done using some networking libraries. These are some of the better know libraries for this purpose.
OkHttp: A complete library with a set of tools for handling network connections and HTTP requests.
RetroFit:Type-safe HTTP client for Android and Java by Square, Inc. which is built on top of OkHttp.
Async-Http-Client:
The Async Http Client library's purpose is to allow Java applications
to easily execute HTTP requests and asynchronously process the HTTP
responses. The library also supports the WebSocket Protocol. The Async
HTTP Client library is simple to use.
There tons of other good libraries.
its called webservices
Through android you get data in form of json from a web server and then return in custom view as you want.
Follow this link hope it will help
Step by Step Method to Access Webservice from Android
you would have to write an API/Web service or use if already exits to fetch data from web server. Basically the concept is that, the website itself must be pulling data from some database, so write an API which would fetch the data from same API and return JSON data and consume the API from your android app.
If you know PHP refere to this for the help :http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php
You can write WebService, in programming it generally refers to a web page(ex. Airbnb), that can be called from your android application which can pass in data to it, or receive data from it.
WebService is basically like a 'method' or 'function' in a normal programming language; except you're calling it over the internet.
The first thing is you have to create a Web Service. The Web Service will be your "bridge" to consume the data from other Website like airbnb or others and return the data to your android through json format for example.
You can create a Web Service using many languages like C#, Java, PHP, etc. I would like to recommend you to use the language that you know the most.
You can try to google this
Cheers
I'm developing a server-client web based application. Clients are mobile phones (android) which should send their data to the server. Their data includes (among other things) images which may be up to 1MB in size. What is the best way for sending these images to the server? A web service? FTP? or something else? Provided we have fast and stable mobile internet connection, can we safely use web service? I can imagine that android device sends image data as raw binary to the webservice and webservice writes these data into database, then website can use these data to display images. Is it a good idea to use webservice for this scenario (specially for large images being up to 1MB in size)? or I should other methods?
I just want to make a TV guide for Android and later some other Mobile Platform. I want to use an RSS updates to update my application. In this specific scenario I want to use http://tvprofil.net/ 's RSS resource. I thought that I could just call site's RSS XML from my Android app, parse it, show, and thats the end of the story.
But, my cousine told me that the best way to do things is through Asp.net Web Api Service. Something to deal with REST. So, If I have to change resource, to like some iptv provider's RSS I would just change the Service and not have to deal anything with my mobile application. Other advantage, he said, is if I want to build Windows Phone application or iOS aplication that works the same way, I would have that same service to do job for me and just create UI and basic things for those apps.
The problem is that I have no idea how Asp.net web Api is used.
Can anyone give me some usefull link, or even better, write an example of this thig. I just want the RSS from http://tvprofil.net/ to go through Asp.Net Web Api Service and that I can call service and get it as XML or ... even Json... or to get anything at all to my app.
The whole thing is pretty confusing to me
If a RSS feed has enough data for your application to function then you do not need ASP.NET Web Api. The only role ASP.NET Web Api could play in this scenario is if it acted as an intermediate. E.g. your client application contacts your server application (ASP.NET Web Api) which in turn pulls the data from the actual external data source (tvprofil.net RSS).
For completeness sake, a list of pro's and con's:
Advantages of using an intermediate server
Reliability. You can cache the data of the external data source and serve that data even while the external data source is offline. Also, by caching the data you can lighten the load on the external data source to a bare minimum.
Transformability. Your intermediate server can translate the data of an external data source to another format that is more suitable for your client application. This is useful when you have many external data sources that each serve data in another format. Your intermediate server acts as a layer of abstraction for your client application.
Disadvantages of using an intermediate server
More effort. It will take more effort to develop and host an intermediate server.
Reliability. You must ensure your intermediate server is online and connected to the internet 24/7
I want to access an online MySQL database in order to retrieve and manipulate data. I read that the best way would be implementing an own web-service, which returns XML and then parse it in Android, is it right?
Does anybody have a basic tutorial?
Since you want to access a remote server which has your DB and other stuff.
You basically have two options.
1 - ) Either directly access your server via sockets etc.
2 - ) Or create a web service which will connect your server to the outside. ( I.e : Android Client,iOs client etc.)
The best practice is to create a web service and then consume it in your Android application.
Check these for consuming XML in Android.
http://www.ibm.com/developerworks/opensource/library/x-android/
http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/
Check these for creating web services on server side. (Stack independent)
http://davidwalsh.name/web-service-php-mysql-xml-json (PHP)
http://www.roseindia.net/webservices/buildingsimplewebservice.shtml (Java)
http://www.codeguru.com/csharp/csharp/cs_webservices/article.php/c19391/Creating-a-NET-Web-Service.htm (.NET)
And so on there are a lot of stacks to create web services.
Again, Webservice is the best approach. But you have to take decision based on the amount of the data being retrieved from the server and how often the transaction needs to be synchnorized with the server.
What Arvind was trying to explain you, incase if the volume of data is too large to download via webservice then you probably need to think of some middle tier that will convert he data to json and send it to your device. The reason, if you are transmitting the 1k of soap response over the air, for the same response, if you are transmitting thro json, it could be 100k or 200k or 300k depends. That way you can save the transmission cost over the net and turnaround time is quicker .
I am dealing with huge data (downloading from webserver to client/phone). Currently I am trying to parse and load complete data into sqlite database when the application launches.
This is taking a lot of time. I want to load the data based on the screen navigation.
How do I achieve that?
You'll want to pass information between your server and the device as XML.
This way the device can request URLs for specific information such as example.com/news/latest (return headlines of the latest 20 news articles), example.com/news/americas (the latest 20 article headlines from the Americas) or example.com/news/article/177309/ (one full article).
The server can then query its database for the needed information based on the query and output it for the client as XML. The client can parse the XML and add the data to it's local SQLiteDatabase.
Is this not restricting the dataset returned from the source first, then downloading it onto the client device?
If you are looking for performance boost up , i prefer running an async task in which the data gets uploaded or downloaded to the server. Its similar to threads but much better.