How to Call Remote Method service? - android

I'm developing in app, in which user can add weather card to know city weather. I'm able to populate cities with Google Places Autocomplete API & also can able to retrieve weather of selected city.
But my problem is as weather data is not fixed, it changes over time. So how can I update weather data in background once user creates that weather card. I need to do updates in background, I think I've to use android service but don't know where to start.

Ok, I will only guide you here,Nobody will provide you full code neither i will recommend anybody to do so, It is for your own good. You need to practice and explore the android programming world. So, here is my guidelines for you.
FirebaseJobDispatcher will fix you problem here. Before moving towards the FirebaseJobDispatcher you need to create a service class. For Services in android you should check this out.
Lets Talk about your service class.
Lets say it is FetchWeatherData class FetchWeatherData will extend to IntentService and will implement some methods. Inside onCreate you will write logic for fetching data from the server. Once you get the data from server you will store into the Database. Before storing into database you should check if database have the any record in it? If it does then delete it and store the new records in it.
Lets Talk about your Activity. Lets say it is ShowWeatherActivity. You will check first if you have any record in your database if there is no record then you will use FetchWeatherData to download weather data. Then show it.
Answer to your question can be very lengthy but i tried to explain as much which can help you get the idea of sync flow. Ofcourse your problem won't solve by reading this answer only. You need to go through these concepts
Services (Runs on main Thread)
Intent-Services (Runs in background)
Sqlite (For storing data)
I have added the helpful links in answer. Follow them. I hope this will help you somewhat.

Related

How can I implement the search for a location?

I am planning on making a widget for android. It will basically show pollution data that is gotten from a government data rest endpoint.
My problem is that I want the user to search for and select the location they want data for, much like the weather widget.
I'm thinking that having a persistence database is overkill because the data probably won't ever change and I don't think the location list very big.
Should I put a textfile in the app that is being searched through or is there another more efficient way to approach this problem?
Thanks in advance!

I want to make quiz app that I can update on daily basis

I want to make an android quiz app that I can update on daily basis.Like update daily General knowledge question answers .New section of question set date vice . I am just a beginner in android and need some guidance . So please guide and give some reference that I can use .
You can use Parse.com for such purpose.
Here is link for parse.com for documentation link for parse.com usage example take start from this site link last but not least do follow official android docs link
As you are saying you are new to Android so keep it simple just make the app to fetch the data from server. The other way is to store the data in SQlite and make your app run offline also.
As you have asked I can update on daily basis
So if you want to updates the question then you can do that from your server itself but if you want to update your app then you need to make your app in generalized manner thinking of your future updates, so that you can easily integrate the future functionalities whenever you needed.
for starters, keep the code and data separate, so you can trigger a fetch from a webserver (in XML or whatever format) with the day's quiz data, then parse and display it from your program. and cache it in a text file so you have something to use in case there is no web connection; nobody likes an app that just hangs.

Store on database vs Retrive data from network

I working on my app that uses "The movie database API".
This app just parse a json from the API and gets each movie information.
My question is what the better way to that.
First alternative is to build syncAdapter, check for updates each day for example, store all movies information on local database and update the UI from database.
Second alternative is just retrive the information from network on each request and update the UI.
Can anyone explain me wich way is better and why?
Absolutely the first alternative !!!!!
let's Suppose your app is used by thousand of users and you have chosen the second one .....oh poor server :)
I usualy create my own local database and syncronize it each "x" interval time depending on the type of information : if I have, for example, a list o category that I know they are rearly changed than I syncronize them each "2 days" ....For data that can be different more often I use 20 minutes and so on. This just avoid stressing server if the user goes in/out from your app.
Bye

How can i insert location into mysql database in android

Hi im developing android app based on location. anyone know is it possible to record live location and insert into MySQL database, so whenever user search it should show the map where he or she went with real time. if anyone knows please give an example
Of course it's possible. You would need to listen for location changes through Android's LocationManager service.
One your app is registered as a listener to the service, you will be given periodical updates about the device's latitude and longitude position. These values are what you should persist in a database.
Obviously, your app would need to ask for a few permissions in order to enable GPS tracking. If you're interested in showing the points aswell, you also need to setup a GoogleMap and request an API key for it to work.
As an addition, Android do not natively support direct writing into a MySql database. Your best bet wpuld be to implement a REST API to act as a middle man between your app and the database (hosted online) and post a write request through said API.
Here's some useful links for you to get started:
Official docs for location strategy
Official docs for LocationManager API
p.s., If my answer sounds too broad to you, it is because the thing you asked demands a broad anwer. Do some research and try to recreate an already existing example. Next time you're posting a question, try to narrow down to the very specific thing you'd want to know.
first you need to get current location location.getlatitude() ,location.getlongitude() then save in variable these variable pass the volley library just simple is that volley network method to save value in mysql database.
if you want to change value in database when user change location you should pass declare the method in locationChanged lisner.
There is no direct way to write into a MySQL database. You need to do a interface e.g. with an REST API.
The simplest way that will fit your need is to write some PHP files that are able to perform writes and reads from the database and POST/GET your data.
I found a pretty good example here:
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

what kind of database solution suits my mobile apps

I am looking into options how to realize the following use case. A iOS/Android user is using my app which gets its table view data populated by a cloud database solution. The user must be able to send back information (e.g. name + date) which needs to be send back to the database and gets stored there in a/different table/s. Moreover, I would need the db-solution to run automated reports based on the information sent back by the users (e.g. in an excel file).
So far I only found ragic.com might suit my needs. But what other options are out there, which might not be as fancy looking but will get the job done. Thanks guys!
A WebService is considered best practice regarding these matters. Have a look at this guys tutorial:
http://android.programmerguru.com/android-webservice-example/

Categories

Resources