I need to get some simple data (actual currency values) to my android application. I'm not sure what is the best way to achieve it. Do I have to make some database and put it on server and than update it manually or there is some better way?
You can use an API Service and access to this service from you android device. You donot need to do a server implementation for this.
e.g. for exchange rates check https://openexchangerates.org/
Yes.
Please make a server and a PHP which going to print out the values in JSON. You can validate your json with http://jsonlint.com/. After it you can download and parse the json with yourself or a 3rd part library (like retrofit).
You can use this website to generate POJO, so retrofit can parse the json for you by it`s own.
http://www.jsonschema2pojo.org/
select: JSON instead of scheme and select GSON instead of JSON, if you are using retrofit.
sources:
https://en.wikipedia.org/wiki/Gson
https://github.com/square/retrofit
http://blog.robinchutaux.com/blog/a-smart-way-to-use-retrofit/
Related
Suppose I have this json file
[{"item_id":"1000","item_name":"PEn","item_quantity":"2.66","item_rate":"3.69","item_purchase_date":"2020-05-13T00:00:00Z"},
{"item_id":"1004","item_name":"box","item_quantity":"63","item_rate":"20.5","item_purchase_date":"2020-06-12T00:00:00Z"}]
I want to make a rest api using this json file in Android. This json file should be locally available in my android device. When I send a certain request (GET/DELETE/etc.) to a certain URL (localhost:3000/posts), I want to perform requested operation.
Please show me how can I achieve this.
UPDATE 1: I don't need NanoHTTPD. (Its better if I can find something like golang with postgres)
To serve an api on an android device, you would need a webserver. The easiest way would be to extend a Java HTTP server and add your own logic.
Try NanoHTTPD, you can easily use it in android.
I created a web site of travel with symfony2, I want to create mobile application using web services created in the web site, I get the data using jsonarry and jsonobject ,how I can insert data using my mobile application.
if there is good library.
thanks.
You can use Retrofit library, see below,
https://square.github.io/retrofit/
https://developer.android.com/reference/java/net/HttpURLConnection.html
you need to use httpurlconnection . you need not use libray for further use but if you want to deserialize and serialize json use GSON .
You can establish connection with web API's using okhttp and can parse json data using Gson library just add compile 'com.google.code.gson:gson:2.2.4' in your build.gradle and parse necessary using MVC method
Check this tutorial https://kylewbanks.com/blog/Tutorial-Android-Parsing-JSON-with-GSON
As we all know parse server being shutdown, but if i want to use parse local data store concept without any parse server interaction(without calling parse initialize(context,appkey,masterkey)) , then how could we achieve this?
Please suggest me if we can use it or not? If not , any best option apart from parse server for local data store?
Thanks in adavance!
You can't use Parse local datastore without parse backend. Objects do not get an objectid until the device is in contact with the Parse backend. Parse pinning is meant as a convenience addition to the backend; not as a replacement.
If you're now considering using ONLY parse local datastore, you should replace your solution with Core Data instead. Or consider setting up your own Parse server at i.e. Heroku.
I have a .net webApi project that contains some methods.
The methods send and get complex objects.
My android application gets the objects in json format and parsing them manually.
In any changes of the objects in the WebApi project I have to change manually the android application project.
I would like to know what is the best practice to work with android application client and .Net WebApi.
There is any tool to connect between them or to auto map the objects?
Please help me
Tal
U do use json parsing technique for parsing the json responses.its proper way of data parsing there is i think no tool for auto mapping.
From the Android Client end you have to use Spring RestTemplate together with Data Transfer Objects (DTOs). You wouldn't need to manually manipulate a JSON String values. It's all about dealing with Java Objects then. You can directly pass the Objects to the RestTemplate as Entity classes and get the JSON String Auto Mapped to your DTOs.
I'm new to both using json and developing for android, however I'm looking to learn how to retrieve information using a json api key.
Let's say this website has all the information I need. How can I access and store that information?
https://website.com/api/user/key/a015b92aec875bd24e8fdc73477bfdcr
For example it would have something like this,
{"balance":"123","due":"3426"}
To access it, you need to open HTTPS connection to the server that has that API key, which is that https address you just provided. The server will return the JSON objects for you, to parse the string data, you can use GSON. GSON will translate all the JSON objects into Java objects, and it will help you populate your pre-built Java data structures with those data
You can get the web content using the Android HTTPClient (or follow something like the guide on this page).
For storage, you need to parse the JSON - see this SO question.
For storage, either store the raw JSON in a file or create an SQLite database and store it according to your specifications.