How to check if Location Services are enabled?

You can use the below code to check whether gps provider and network providers are enabled or not. LocationManager lm = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE); boolean gps_enabled = false; boolean network_enabled = false; try { gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); } catch(Exception ex) {} try { network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); } catch(Exception ex) {} if(!gps_enabled && !network_enabled) { // notify user … Read more

What’s the difference between window.location= and window.location.replace()?

window.location adds an item to your history in that you can (or should be able to) click “Back” and go back to the current page. window.location.replace replaces the current history item so you can’t go back to it. See window.location: assign(url): Load the document at the provided URL. replace(url):Replace the current document with the one … Read more

window.location.href and window.open () methods in JavaScript

window.location.href is not a method, it’s a property that will tell you the current URL location of the browser. Changing the value of the property will redirect the page. window.open() is a method that you can pass a URL to that you want to open in a new window. For example: window.location.href example: window.location.href=”http://www.google.com”; //Will … Read more

Location Services not working in iOS 8

I ended up solving my own problem. Apparently in iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates. There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt. Adding these solved my … Read more

How do I get the current GPS location programmatically in Android?

I have created a small application with step by step description to get current location’s GPS coordinates. Complete example source code is in Get Current Location coordinates , City name – in Android. See how it works: All we need to do is add this permission in the manifest file: <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” /> And create … Read more

What is the simplest and most robust way to get the user’s current location on Android?

Here’s what I do: First of all I check what providers are enabled. Some may be disabled on the device, some may be disabled in application manifest. If any provider is available I start location listeners and timeout timer. It’s 20 seconds in my example, may not be enough for GPS so you can enlarge … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)