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/
Related
I would like to preface my query by saying that I am an absolute beginner when it comes to programming but I really want to realise this project so every little help is deeply appreciated.
I am trying to build an app that needs accurate train data for it to work and from my current research as there is not central government API for railway data , the only accurate data source for train location that I can find is in an other app that uses crowd sourcing to pinpoint the location.
I wanted to know if it is possible to fetch that train data from that app and then use it on my own as it would make my app a lot more reliable and accurate.
The issue currently is that the app only shows graphical representation of the data thats being fed to it from its servers , so I wanted to know if there is a way to access the actual data being sent to the app.
Thank you.
Let me clarify, this is a very broad question and hence will have a very broad answer too.
As far as I can understand from your question is that you want to show TRUE location on a map.
For this, you will have to understand the complete Tracking scenario. Let me explain it to you step-wise below:
There is an app, installed on a device (user) which fetches the GPS location (REAL) data and keeps sending it to a server (backend).
This GPS data is the Lattitude-Longitude coordinates of the device (user).
The server stores this information in their database for queries.
There is another user, different than the one currently sending the location data, who wants to know the location of the first user. The app which he is using will request the server (backend) to send the location data for the device. Which, in turn, will send the latest location data (LatLng coordinates) to the current app. This app will then show the location data over a map.
Now, usually, this process is followed to show one-to-one location data. However, in scenarios like Train Location etc, servers usually collect pool of location data, being received from several users, to cross-verify the actual location (average out, mean, location optimization algorithms etc.) and then display that information over a map.
As per your requirement, which I can understand, you want to get this REAL data directly from either another app or from the server. If you want to get the location data from the server, you will need an API, which serves as a Request-Response platform. However, if you are looking to get the data from another app, it would rather be simpler to get the location data directly, as your APP will also be installed on the device itself.
I would suggest you to kindly read about getting and processing location data, communication with servers over API etc for better understanding and implementation of your requirements.
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.
Using Android Studio, what sort of things are needed when trying to compare a specific user's location to every other user. For example if there are 1000 simultaneous users, and I want to find the closest one(or farthest) to any given user, what sort of calculations need to be done?
If each user's locations were saved to a DB, where do I start? Is it necessary to compare one location against the 1000 (or more) users to find the closest, or would it make more sense to make some type of cut-off (i.e. only compare users who are within 50km).
It seems overwhelming and I am new to android, so I am unsure where to even start. Parse.com and Pubnub are being used in this project.
Geohashing by User Proximity Tutorial
I'll reference for you here the geohashing tutorial that walks you through how to build a realtime app that connects users based on relative location.
Note that this example is written in JavaScript and not Java/Android. However you can still use this design pattern to determine proximity.
App Geo Location: https://www.pubnub.com/blog/2014-05-07-geohashing-chat-by-proximity/
There is also a short video which discusses the Geohasing concept.
Adding in Parse SDK and Location Comparison
Also you can add in this link: Parse reference guide. And a Parse Connector SDK if needed.
I wanted to venture into making apps. I wanted to make an app that gathers the events around the user location wise. I want the app to show the events close to user using the GPS of the phone. There is a city page where all the events are listed but I don't have any ideas how I will be able to fetch the data. What are the other ways I can go forward with this? It would be encouraging so that I can research further.
try this
http://www.last.fm/api/show/geo.getEvents
login this and get the api calls and use it in your code
i think you can use a combination of api's to give you the data you are looking for, one such provider i found was http://api.eventful.com/, you can probably even try including foursqaure and meetup's api and even facebook opengraph event api can also provide some handy data.
i am newbie to Android..i have latitude and longitude details in my program..i want to send them to web server via gps..and those details should be saved in a database and retrieve them whenever i require..plz explain me how to do..and if possible give me some sample code...
Did you mean the mobile network or wireless instead of GPS ?
Anyway:
You from the sounds of it you need to get the GPS details into your program then pass them to your server. Have you designed your webserver yet or are you going to be submitting this to a site that already exists?
You can't "send" something "via GPS". GPS is a "receive-only" thing.
http://en.wikipedia.org/wiki/Global_Positioning_System
If you like to send data to a web server, you can use the HTTP-protocol with Android, e.g. retrieve latitude and longitude (How to get Latitude and Longitude of the mobile device in android?) and then use HttpGet (or HttpPost):
http://developer.android.com/reference/org/apache/http/client/methods/HttpGet.html
You're really asking for a lot, but lets see if we can point you in the right directions.
Here is a great example of reading GPS data from an Android device:
LocationManager example
You must declare explicitly in Android that your app needs permission to access the Internet (and the GPS, for that matter).
Android Securty and Permissions
There are also some specific ways of life in Android development. The official developer's guide is a good place to start.
The Android Developer's Guide