last day (14 days later) » 

6:59 AM
0
Q: Couldn't get user location

Usman RiazI am trying to get user location either network location or gps location or both. for that i am running a background service which implements LocationListener. i added all the require permissions in the manifest file also. here is my service public class GetLocation extends Service implements Lo...

 
If you are testing inside building, GPS won't work. Please go outside once, and test.
 
@Dhruti yes i'm sitting inside the basement of a building. but how about network location? isn't that supposed to be not null?
@NaveenTamrakar checking on real device
 
Are you getting Toast of "Getting location Via Network"?
 
@PG_Android No gps is not on, but i should get the network location
@Dhruti no i am not getting it, i don't know why
 
@UsmanRiaz means, its not going in that if condition block of lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER). Make sure NetworkProvider is enabled.
 
6:59 AM
@Dhruti yes, i couldn't send my sms either. now i am going to try it out with network enabled.
 
@UsmanRiaz Good luck :)
 
@Dhruti now that network is enables and i am sending receiving my sms also but again not getting network location :-(
 
any error in logcat? Toast shown?
 
gps is enabled so i am getting gps toast but no network toast. it still beleive my network is disabled. but i am getting sms from my network
 
hey @UsmanRiaz
check this
have you checked that in your device settings?
 
6:59 AM
hey i am here
what settings?
 
2
A: isProviderEnabled(LocationManager.NETWORK_PROVIDER) return false

Jeremy EdwardsMake sure that network based location is enabled in the phone's settings. You can detect this situation and prompt the user to enable it if you really need it. I believe this is the line of code to launch this activity. activity.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION...

like shown in screenshot in this post
device- settings > location services
 
let me check
 
access location >
it must be checked.
Ya, check and make sure its on.. then test
Google's location services should also be checked
The second checkbox...
 
yahoooooooooooooo
thanks
thanks thanks thanks thanks
my network locations were off
ans my question and i'll mark it as ans
 
Great :) congo..
ok :) adding...
 
7:04 AM
hey
 
ya..
 
is it personal chat? i didn't know this chat thing
 
Just SO chat facility...
Added answer :) happy coding..
 
hey can i leave you my email address just to ask some questions in case????
 
you can ping me here in case you need help :)
 
7:08 AM
what's is it? a chat room ?
 
yes.
 
okay thanks dude
you saved my day
 
welcome :)
@UsmanRiaz :)
 
If my gps is enabled and i am getting the loctaion via it but if suddenly i disable it then will it remove gps location updates from location manager automatically
 
I think yes..
Haven't implemented GPS yet, so can't say surely. But in my opinion..
 
7:17 AM
ive got 2 call back method, onProviderEnabled() and onProviderDisabled() in Enabled method i am checking which provider is just enabled then calling this method of locaitonManager lm.requestLocationUpdates(provider, 10, 1000*60*1, this);
and in disabled method, i am doing nothing ? is that make sense?
 
Depends on you..
You can show alert to user or toast..
if you want to...
Update UI, (e.g. update textview that GPS is currently disabled. Will check for update when enabled)
Anything..
 
if my app is running or service to be specific , if gps is turned on by user then in the onProviderEnabled() method i call lm.requestLocationUpdates(provider, 10, 1000*60*1, this)
does that make sense ?
 
i think so..
 
okay thans shruti
dhruti
 
:D :)
 

last day (14 days later) »