I Want get location with Wifi and work in Google map, and it's not work for me but Gps is okay and not problem.
my code:
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
if (locationManager != null) {
boolean gpsIsEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean networkIsEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (gpsIsEnabled) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 5000L, 10F,
(android.location.LocationListener) this);
} else if (networkIsEnabled) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 5000L, 10F,
(android.location.LocationListener) this);
} else {
// Show an error dialog that GPS is disabled...
}
} else {
// Show some generic error dialog because something must have gone
// wrong with location manager.
}
AndroidManifest:
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB4C_zHeHYMTWqW4_Wpin-5jLF9S54KDSQ" />
</application>
<permission
android:name="com.karyan.karyanmap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.karyan.karyanmap.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-feature android:name="android.hardware.wifi" android:required="true"/>
<uses-feature
android:name="android.hardware.camera"
android:required="false" >
</uses-feature>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
Newtork_Provider is null when wifi in connected to Intenet.. How to Resolve Problem
thanks..