Android Application Backend from scratch - android

I am developing an android application which needs a backend to process login and store data remotely on a server. I have previously worked with a BaaS service "Parse" for android. but since this is my final year project for my university I need to develop a backend from scratch, I have never worked with web services. I need some guidance on how to approach this and which framework will be the best to work with.
Thanks in advance.

If I understand you correctly you want to build a server application that allows you query data from your android app?
I'm not an expert on this since i just started coding myself, but I did do some research and it seems to be a very viable option to implement a RESTful API on the server side. The wiki article is pretty specific about how it works.
If you can use PHP the slim framework allows you to get a scrappy prototype RESTful API up in less then an hour if you familiar with the server configuration. It seems to be sophisticated enough to drive small and medium sized projects (maybe even big projects; I can't tell to be honest.)
On the start page you can see an example that allows you to query for a "hello, world" string from the API with less then 50 lines of code.
http://www.slimframework.com/
Where the example returns a "hello world" string you would perform database queries using PHP and return your results as json objects to your client.
The benefits of this are that you can use this Backend for different clients: Android, iOS or even your own browser-based web application.
This also makes it easy replace / port the backend once requirements change since it's very easy to implement the same API using other technologies and languages that fit the requirements better.

Related

How to make the server backend of a mobile app?

I am an Android developer and I want to make an app which shows users on a map and performs tasks based on their location.
The whole model of the app has to run in the server. I need an API which:
Receives user location
Performs calculations based on the location of the users
Sends response to specific users with the results
The problem is that I have 0 experience in doing server side programming.
Can you please suggest me a way of making the server?
I checked the Google Colud Platform and this video. The video addresses the connection between the app and the server, but what I really need is coding the model and deploying it on the cloud.
What is the way for me to build the API for such an app, as a developer with no server side programming experience?
Can you suggest me a tutorial which goes trough the process of building a cloud backend for a mobile app?
This is a very complex question. I don't recommend using a "ready-made" solution like FireBase because it's even harder to transform it into a "proper" API later on when you need it. If you know Android then you know Java, you'll have no problem learning working with a framework like Spring Framework which I recommend. Java on the backend needs a Java Servlet container, like Tomcat. First you should set up a development environment on your machine for this. I recommend searching for Spring Framework tutorials for this i.e. Spring Framework REST tutorials.
Secondly you'll need a database like MySql or MongoDB to store data. Spring comes with ready made connections to most of the most common databases, so its pretty easy to work with them.
When you're ready to deploy your service I recommend using a PAAS like Heroku.com where you can run your service for free first. In this way you get to control everything yourself and you also learn a useful skill.
Since you are coming from the JAVA background you just need some basic building blocks and you shall be good to go.
Use PASS: They will take any devops from your side which will be a big relief considering you are not familiar with anything on server side. I recommend using Heroku or App Engine. Here's guide to App Engine with JAVA on top. https://cloud.google.com/appengine/docs/java/
Database: Not sure how you are storing and managing your user data as of now, but if you need database, there are various of those available now. The reason Firebase is top suggestion, cause it leverages realtime and gives you control on your side without spending a lot of time on your side.
APIs: You will be taking user's geo-location and sending it to server. On server you will need to process that into a real world location and any other logic. You will need to use Google's GeoLocation and reverse geocoding APIs for that. Find apis here : https://console.cloud.google.com/apis/
Also if it's any help, App Engine and Heroku both offer free limits and should be pretty sufficient for your use case.
Since you have limited experience on server side development I'd suggest using a backend-as-a-service platform. This approach has the benefits of allowing you to focus your time coding the client where your competitive differentiators are, and lets you leverage years of experience in server-side development without having to ramp up on the technology. It also means you can iterate quickly and test features ideas with less risk.
There are several options out there, but in your case, you'll need something that provides enough flexibility to implement custom logic and a custom data model. Some platforms allow you to create a full backend application with REST api endpoints, and automatically take care of deployment, security and management. Some examples of backend service providers can be found here https://en.wikipedia.org/wiki/Mobile_backend_as_a_service.
Some of the platforms actually allow you to build a full custom app without actually writing any code, and some of them provide ready-made components (like chat, leaderboards etc) but are less flexible.
Here's a list of Backend-as-a-service providers:
https://quickblox.com/
https://www.appcelerator.com/
http://www.configure.it/
https://cloudboost.io/
http://api.shephertz.com/
https://backendless.com/
http://pipegears.com (No coding required)
You didn't provide specific details about the tasks you want to implement on the backend, but it's likely that you could satisfy your requirements with a straightforward REST api that accepts your location data, runs business logic, reads or writes from your data model and returns whatever data your client needs. (Sorry I can't get more specific without details on your requirements). If you're dealing in sensitive information like location data, I'd strongly recommend securing the api with TLS/SSL (i.e. https), or make sure the platform you use provides this.

Web application + Mobile App Python/Django architecture

I'm starting a new side project in order to learn some new technologies and I have several doubts about the architecture I should use. My idea is developing an app both for web and for mobile (Android app mainly), so I think I need to implement the following:
REST API service (with django-rest-framework).
Web application (with django).
Android app.
After researching over stack overflow and Internet I have found 3 main "architectures" for the web part (server-rendering, client-rendering, and an hybrid model). In first place my idea was using the client-rendering model (with backbone or angular for the web client). However, I have seen that the hybrid model is a better choice.
So here are my doubts:
1) Could I use django for server-rendering the web application pages?
2) Does Django web app "use" the API or the API is implemented using the same "library" as the django web?
3) Could/should I use a client framework (angular, backbone) for the web client (being server-rendered) ?
Thanks in advance, and sorry about my short knowledge about django, etc.. This side project is just for that, to improve my knowledge about all this stuff.
I don't use Django but I am currently using Angular with Flask as my REST backend. I think the hybrid approach is useful if your app benefits from caching rendered content. An example would be something like a blogging site where you may store Markdown but render HTML and thus the content is largely unchanging. If this content is shared across many users it can be very beneficial to generate once on the server and serve it to many clients.
However if your reasoning is that because mobiles are relatively under-powered server-side rendering will improve the render time, this does not necessarily hold true. Serving the JSON data model will typically result in less network traffic (obviously dependent on browser caching) which is important for mobile client responsiveness.
For my own part I prefer to render on the client and keep the server-side rendering to some very minimal templates. I find this results in a much better REST API that I can then use to provide external developer access or plug in other client UIs. My client code lives on the client side in Angular, my REST interface is clean, and security is always uppermost in my mind because I have to assume that the client code is potentially hostile.
That said I can see a use for server-side rendering even with Angular. For content that is fairly static it would be great to generate this server side, cache it, and then ngInclude it.

Using Azure to develop website then create native iOS and Android app for it later, what would be good data architecture?

I have built a blog using Windows Azure and .NET MVC.
This was my only experience for web development, so I am still pretty new in this area.
I just got an idea for my second website and I plan to develop native iOS/Android/windows app for it later on.
I am going to use Windows Azure SQL database and .NET MVC again for this, but I wonder if this is good choice for my future development for mobile app as well. Can my mobile app easily get access to data hosted in Azure SQL? If so could you let me know in which way? any suggestion is welcome, thanks!
A service-oriented architecture decouples the back end from how it is displayed.
You can use SOAP or REST services to fulfill each use case.
Come up with a protocol/contract that the services expose and any client that can make HTTP requests can work with them.
Take a look at Windows Azure Mobile Services (http://www.windowsazure.com/mobile). Mobile Services is a backend as a service you can use for your data storage from your asp.net site (from the C# code behind) and then when you're ready to build your mobile apps, you can use the exact same interfaces from the native Objective-C iOS / Java Android / .NET Windows SDKs. This will save you from needing to write the service layer if you don't want to spend time doing that.
Since your comfortable with ASP.NET MVC, I would recommend you build the website in MVC, but then have it call into a service layer that exposes the functions desired using ASP.NET Web API.
This would be an easy fit as you can then build your native mobile app later, and just call the API using JSON as the data format.
Great question by the way!

Android - Connect to MSSQL online database

I'm new to Android programming. I have a website with sql 2008 db, and now i would like to give the users the ability to use their smart phones to enter data to this db.
I was wondering what is the best way to establish it. Since I'm new to it I don't want to build something that's not so professional.
Thanks for your help.
If I were you I would consider two following options:
Have a web application optimised for mobile use;
Pros:
Updates are delivered immediately, as there's no client application, everything is done on the server;
Web application can be used on many devices with a browser and not just Android: iPhone, Blackberry, PC, Mac, etc.;
Cons:
Users need to be online to work with the application;
You can not leverage from the native UI components available to native device applications;
Write Android application that will work with the database via a number of REST endpoints exposed through a web application (again);
The pros and cons are a full reverse of what you had in the first option.
The right answer for me was to use KSoap library. I'ts very easy and works very well.
Here is a tutorial that will show you how to do it step by step.
http://java.dzone.com/articles/invoke-webservices-android

Recommendations for .NET Web Service Format/Protocol for Android, iPhone, etc. integration

I am building a web service for my ASP.NET MVC 3 website. Ideally I would like all clients (my web pages, iphone application, android application, windows phone 7 application, etc.) to use the same service layer to load and save data.
I am new to mobile development and was wondering if there is a preferred mechanism - SOAP/JSON/etc - to use a heterogeneous mobile device setup. Specifically I'm wondering if Android and iOS have better libraries/support for one protocol over another or if the main mobile platforms have strong support for all protocols. I am also wondering if all is even when it comes to securing said services.
Any advice would be much appreciated
Thanks
JP
I would suggest a REST(ful) service with JSON.
Both Android and iOS have libraries that support parsing XML and JSON, however the JSON libraries are a bit easier to use and are a little bit faster.
With a little more effort you could allow your service to provide/consume both XML and JSON.
It would be preferable to avoid SOAP as it is more verbose and not as suitable for the more bandwidth/battery sensitive mobile devices.
This would be a great opportunity for you to try out WCF Data services, together with Entity Framework. You can build it very fast, and it exposes your information model using the OData international standard in both XML and JSON flavor. The interface is accessible throught REST. No problems interacting with any front-end technology, fat, web or mobile clients.
AND, you have all the benefits of re-using your C# .NET knowledge, visual studio and created assemblies to also make more tighter integration with Windows applications if you need to. It certainly did the trick for me!
So:
Create your application model using Entity Framework. Either database first if you already have a physical datamodel, or model first is you are starting from scratch.
Expose the created information model using WCF dataservices (5 lines of code)
You can find a walkthrough at: http://msdn.microsoft.com/en-us/magazine/ee336128.aspx
Happy coding!
I have almost same situation and what am I doing is, I am making WCFrest services for android and iphone.
In terms of the security, I am using role based membership provider. So i have created a user for the mobile clients with the role of 'Mobile clients' and give the user id (guid) as an 'api key' to the android and iphone developer.
The iphone and android developer has to send the 'api key' in the header of the request.
so before executing any method in my wcf, i am checking the api key and also checking if the request is from an android or iphone device.
I hope this will help you a little to plan your development..:)
Try using ksoap2 and have your WCF services use the basicHTTP binding.
If you have only primitive types as parameters, this should very easy. With some work you can also use it for more complex types.

Categories

Resources