I need to build a Native Android Application for a Website that I have successfully developed. How do I go about this without using the webView. Someone talked about REST API But I don't just know how to go about it.
Although I have the Application in webView Version already but it is just still as the normal website mobile view. No Interactivity.
Your solution is REST API. Here is a good example.
How to create REST API for Android app using PHP, Slim and MySQL
Basically schema should looks like backend(all your data) - Rest Api (you must provide interface to your backend data with CRUD operation like PUT-DELETE-UPDATE-RETREIVE) - users for your Rest Api (mobile apps that would call this api to use data from backend)
For backend look at this tutorial to start https://www.youtube.com/watch?v=xkKcdK1u95s&list=PLqq-6Pq4lTTZh5U8RbdXq0WaYvZBz2rbn
For android app you should use Retrofit2 to facilitate RestApi calls.
Related
I have a web application developed with RoR, and I was wondering if it was plausible to use it as the backend for an Android application that I would develop in Java or Kotlin?
For example, if the web applications authentication is handled with devise, can I get the Android application to send the name and password to my web application and have it return the user as a JSON?
Absolutely you can.
Usually the Android app would call an API rather than a web page. That is you don't exchange HTML like a browser does, just the essential JSON. Lots of things work the same as a web site. For example you can use the same authentication mechanism for the API as for the web-site.
This is a good starting point for RoR to create an API.
https://guides.rubyonrails.org/api_app.html
Here's a starter for Android making a web-service call:
https://developer.android.com/training/volley/simple
That's just a get, which you might use to get a list of something that's publicly available. It's probably worth understanding the other pages just there because with web calls it's really easy to do bad things like lock up the UI thread, so best to use the example patterns and methods.
I already have an ASP MVC web application with authentication and authorization.
and now I am working on an android application which will perform almost the same thing as my web application does.
I can use my ASP MVC web application to return json data to my android application, but as I've searched a lot and I was suggested to use Web API for android application.
my question is does it worth to make a dedicated web API with Authentication and Authorization (coz ASP MVC's Authorization is different from Web API's).
Please advice me, would it be any problem if I kept using my ASP MVC web application as json API for android application ?.
you can use an MVC application, you can have some controllers which return JSON data only and call those from anywhere. You still need to authenticate the access to them when you call them from another app though.
Your other option would be to rework your architecture a little. Create a proper WebApi, sort out the authentication to it.
Once you do that, you can call it from both your MVC and any other app that you have, the same way. This way you keep things consistent and your data comes from one place.
If you call your MVC controllers from another app you are basically putting the pressure on the MVC app which now needs to serve an external app as well. Too many calls will then affect the performance of your MVC app.
It's much easier to scale an API properly instead.
I prefer to add JWT security to my APIs. Then your MVC app becomes a client, the mobile app another client, if you need to add some user information, you can, you can also add extra claims to your tokens if and when needed.
Have a look here :
https://jwt.io/introduction/
https://devblogs.microsoft.com/aspnet/jwt-validation-and-authorization-in-asp-net-core/
I used IdentityServer 3 7 4 with good results in the past: https://github.com/IdentityServer/IdentityServer4
So I have implemented ElasticSearch API using Amazon Web Services. Now as the Android Application is currently in testing mode
I am building an Android Application where there is one Search feature for user where I have used ElasticSearch API from Amazon Web Services. Now the question is how to secure that API Request.
I have so far seen the policy based authentication, Shield. I want something of a token based authentication like restful api's.
Is there something out there for this or a different approach in android application for searching.
You could use AWS Lambda that will act as an auth layer.
If you are using a server already then you can do something like the image below. If you are hitting ElasticSearch from your Android App then maybe something like this custom plugin, but I don't know if your provider (AWS) permits the installation of custom plugins.
You can find an interesting conversation on this thread. Maybe something that fits your use case will come up.
I've tried to understand how to fetch data from joomla database with android app but i didn't found what i was looking for.
In the past i've used Joomla api to use joomla database with php custom pages.
Are there some API to use with android? or do i have to write some webservice and use them to make android and joomla DB interact? if this is the only way i have to follow, could you explain me what i have to do or where i could find a good guide to study how to write a good webservice to interact with joomla and how to read it ?
Thanks for the help!!
You need to write a web service that exposes the Joomla data through an API. You need two things
Joomla server/service which would probably need some way of Authenticating the user which could be oAuth or preshared secret
Android client that will connect to the service, authenticate and consume the API and the data
You can check this library which allows you to build REST API on top of Joomla: https://github.com/techjoomla/com_api
Also if you don't need the Joomla functionality but just the data from the database you don't need to plugin your API in Joomla structure itself. Build a standalone REST API/service that will allow your Android app to connect directly without interfering with the Joomla website processes. Thus if you need to do some optimisations to the API or Joomla (e.g. upgrade) you don't need to take both down as they'll be loosely coupled.
For building a RESTful API with oAuth authentication you can go down many routes. One option would be using Laravel and oAuth server and a simple API that will plug in your database and generate JSON output.
Laravel - http://laravel.com/
oAuth Server
https://github.com/lucadegasperi/oauth2-server-laravel
https://github.com/thomaswelton/laravel-oauth
REST API
https://github.com/dingo/api
pull those libraries together and you have a working service
On the Android side you have to build the client authentication and JSON parser to map it to your model classes:
oAuth Client
https://github.com/wuman/android-oauth-client
https://code.google.com/p/google-oauth-java-client/wiki/Setup
http://nilvec.com/implementing-client-side-oauth-on-android.html
JSON parser - http://code.google.com/p/google-gson/
I'm writing an android app for a web service like Twitter using its APIs, and I've chosen RoboSpice to make it easier to perform network requests and deal with cache. But I don't know how can I combine the APIs with RoboSpice.
In RoboSpice's starter guide, they used GitHub's follower API as an example, but they wrote the URL right inside the loadDataFromNetwork method, does this mean they want to do all the works like this to all the APIs there? At the same time they transfer the JSON to POJO, but they didn't show what to do with the POJO next.
I'd like to know if there is any best practice with using web APIs in android app.