How to develop native android app?

How do you do the following to develop an Android app?

  • 1) When the app is started, it should check if GPS is enabled or not. If it is disabled, it should pop up asking user that, GPS has to be enabled in order to use the service? 2) When the app starts( and say if GPS is on), it should directly point to current location of the mobile phone. It should be zoomed as much as the Google maps allows. Please help me how to do these. Stackoverflow allows only to post questions with code.

  • Answer:

    You're going to want to take a look here: http://developer.android.com/guide/topics/location/strategies.html The key part is that most of the GPS pop-up should be handled for you if you put the right permissions in the manifest. You're supposed to use the Google Maps v2 API when you have this GPS location, and I've included it below. Don't read much past "maintaining a current best estimate" as you can get what you ask for in the beginning.  Ultimately these are the two lines of critical code you'll need to get working: String locationProvider = LocationManager.NETWORK_PROVIDER; // Or, use GPS location data: // String locationProvider = LocationManager.GPS_PROVIDER; locationManager.requestLocationUpdates(locationProvider, 0, 0, locationListener); And: Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider); As for a MapView, take a look at this document: https://developers.google.com/maps/documentation/android/ You want to power your map with this GPS data after you get it from the Location Manager.  Good luck and happy coding!

Adam Schwem at Quora Visit the source

Was this solution helpful to you?

Other answers

Most of time, the most usefull imformation is the official API document! I am sure that in a  addition to fix you problems,you can learn sth that more than you want. https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2

Austen Chan

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.