How to interact with python script on local server in Android - android

How to send user text for processing to python script running on a local server and get JSON object back and display that in our app.

This question is not about android studio. If I were you, I would look to python web frameworks which can help you to create a REST API. I usually use Django for big and complex projects, Flask for simple http, Tornado for websockets. In your situation I'd rather use Flask with Mongo no-sql database.
You can also use something like Ngrok to share your local api through the internet.
Here is the tutorial about flask, there are many of them in google, you can choose any.
https://medium.com/python-pandemonium/build-simple-restful-api-with-python-and-flask-part-1-fae9ff66a706
If you have big project with complex backend, my advice will be to use Django and Django REST Framework, there is a lot of information about them in official docs, and also there are good courses on Udemy by Justin Mitchell.
Just follow some flask tutorials and it will be simple to implement what you want

Related

Android Application Backend from scratch

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.

developing an android application with servlet

I'm currently developing an android application. My application allows users to choose a picture from a gallery, add a comment and send it to the server. The server then saves it in database.
Currently I'm using HttpUrlConnection at client side and Dynamic Web Project with a servlet to process on server (I'm using eclipse with Apache Tomcat)
So the questions are:
Is it a proper use of this technology to develop my app. (does it violate any rules? Sorry I'm a newbie)
Does this technology affect anything if i want to expand my app?
Are there any better technologies to use in this situation and is it worth to use it?
No I think it is a better way to develop this. I have also develop a chat based app usign the same technologies.
It doesn't violate any rules. There are many apps in the market usign the same technologies.
Q-3.Are there any better technologies to use in this situation and is it worth to use it?
You can also use php or any other server side scripting language to do the same.
Because when you want to host your java app you may find difficulty for java hosting but for php and asp you can easily find hosting services.
I answer in order:
1- the client is different, the client is recomended create an android application.
2-You need have clear this: Android is an application, the server has to attend petition from android. The conection could be using webservices, API rest, or others ways.
3-Android need Java to be native, in the server side you can use, Ruby, PHP, Java, Python or any server programming languaje side. Is your choice.

Python framework choice

I know this is a bit off topic, but I really needed some help regarding this.
I am new to Python. I'm trying to build my next project (a dictionary web app which will have both iOS and android app as well) for myself in Python. I've done some research and listed out some promising frameworks.
django
pylons (pyramid + repoze.bfg)
tornado
CherryPy
pyjamas
flask
web.py
etc
But while django is great, it was originally built for newspaper like sites project building. Im stuck with choice making for dictionary like web application which will have to provide RESTful web service api for mobile request handling.
So anyone can you please help in pointing out which framework is the best choice for this type of web app. I think I should go with django. Or should I go with native python coding? Any suggestions will be great.
Django's strength is in it's ORM, huge documentation, and the thousands of reusable applications. The problem with those reusable apps is that the majority is written following Django's MVC design, and as you need a web service, and not a website or web application, most of those apps will be almost useless for you.
On the other hand, there is Django-REST-Framework, extending Django itself, which is pretty good, and it's declarative API feels as if it was part of Django itself. For simple cases just a couple lines of code could produce you a complete CRUD API following REST conventions, generating beautiful URLs, out-of-the box support for multiple authentication mechanisms, etc. but it could be an overkill to pick Django just because of that, especially if you do not wish to use it's ORM.
Flask on the other hand is pretty lightweight, and it's not an MVC-only framework, so in combination with Flask-RESTful, I think it would be an ideal tool for writing REST services.
So a conclusion would be that Django provides the best out-of-the-box experience, but Flask's simplicity and size is too compelling to ignore it.
Go with Django, ignore its entire templating system(used to generate web pages) and use Django-Tastypie for REST service. Easy to learn and set-up is instant.

Implementing sync from mobile app to server in .net

I'm planning a mobile app, to be built using phonegap, that will sync user data with a server. The data can be edited on the app or via a web interface on the server, and some users will have multiple devices so need to sync to them all.
Anyone know of good guidelines/tutorials/patterns for this sort of thing? I can hand-code it all but I'm sure I'll make lots of common mistakes and it'd be better to either use a library or follow some good rules.
If I was doing the server in java then something like OpenMobster sounds good.
have you checked out the Sync Framework Toolkit?
I am looking to do the same thing and have found https://github.com/orbitaloop/WebSqlSync/. I have not used it in anger yet, but it looks good.
Just so that there is no stone left unturned in your research.
To use OpenMobster your server does not have to be in Java. It helps if it is, but you can have your server in any language or platform. All you have to do is expose your data via a secure REST API.
You then write the OpenMobster Sync Channel that accesses data via this REST interface. Yes, this Sync Channel has to be written in Java as it plugs into the core Sync Engine.
So architecturally speaking, you would have the OpenMobster server between your server and the mobile device.
This is the same architecture when mobilizing legacy databases, CRM systems, ERP servers, SalesForce.com, etc
Full Disclosure: I am the Chief Engineer of OpenMobster project

Django for web-service for Android client

I creating a client on Android to interface with a web-service I would like to create using django. I was was wondering if anyone knows of any good projects or examples to make this easier. I recall a great django api module, but I have been unable to find it again (I will keep looking). On the Android side, I could use any advice (json vs xml, ...etc)
I have a similar project and use django-piston on the server side. You can export to many formats (XML, Json, etc) but I prefer Json.
On the client side I use Sencha Touch to create the interface in HTML5, so it is platform independent. We deploy on Android and iOS. Sencha also makes it very easy to consume Json and even store the data offline.
Django Piston works well for creating an API. I used it to create an Android interface recently and it seemed to do the trick. It supports exporting data in XML, YAML, JSON, etc, and you can create your own output formats. You can get it to work with oauth and basic http authentication.
Anyway, might be worth a look.

Categories

Resources