[android-developers] Re: Android on device GPS locate not working - code included
Our application also use GPS and it works as well as the maps application, and we tested it on the G1. Did you call requestUpdates on the LocationManager ? 2008/11/7 Amir [EMAIL PROTECTED] OK Android enthusiasts...here's where the GPS story has led us. We figured out after hard-coding a location via finding latitude and longitude of my house that the application via the G1 does in-fact communicate flawlessly with our website. The issue though is turning on GPS capabilities on the device via private void updateLocation(Location loc). Basically, we did notice that when using the maps application on the G1, a 'GPS' icon is presented on the top right side of the phone. We aren't seeing this through our application and we believe it's because the function, private void updateLocation(Location loc) never gets executed... Any thoughts? Does anyone know what needs to be done to initiate this function? Cheers Amir On Nov 5, 9:48 am, Amir [EMAIL PROTECTED] wrote: Hah...no worries and good check on the permissions query, I'm trying something new today as well as hard-coding a location to see if my app can sniff it out. I'll let everyone know about the outcome! Amir On Nov 4, 5:42 pm, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Amir, I'm sorry... permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) Keiji, Amirwrote: Hi Guillaume, Thanks for your reply and yes the standard map application manager does display my location on the G1, but my application doesn't allow display to my website just yet. Any thoughts you may have that might help? What I see on the device is the GPS icon is turned on when my application is running, but no data is transmitted to my Google map that's on my website where I can track where I am. Cheers Amir On Nov 4, 12:17 pm, Guillaume Perrot [EMAIL PROTECTED] wrote: Did you check if the standard map application manages to display your location ? 2008/11/4Amir[EMAIL PROTECTED] Thanks, I'm still having issues, but now I do see the GPS 'icon' as turned on when the application is running. The issue though is that I don't get anything on the map through our online site...no longitude and latitude, or anything else. Here's the revised code I'm using: package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class LocationService extends AService { LocationManager lm = null; Location loc = null; public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); loc = lm.getLastKnownLocation(gps); if(loc == null) loc = lm.getLastKnownLocation(network); double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+,+sLongitude; //location = 40.738412973944534,-73.98468017578125; getDataMap().put(Des, OK); getDataMap().put(Value, location); } else { getDataMap().put(Des, error password!!); } new ServiceClient(this).excute(); return 0; } } On Nov 2, 8:46 am, Akbur [EMAIL PROTECTED] wrote: Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: HiAmir, I had encountered a same situation. But my case is about getLastKnownLocation(String)
[android-developers] Re: Android on device GPS locate not working - code included
Hah...no worries and good check on the permissions query, I'm trying something new today as well as hard-coding a location to see if my app can sniff it out. I'll let everyone know about the outcome! Amir On Nov 4, 5:42 pm, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Amir, I'm sorry... permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) Keiji, Amir wrote: Hi Guillaume, Thanks for your reply and yes the standard map application manager does display my location on the G1, but my application doesn't allow display to my website just yet. Any thoughts you may have that might help? What I see on the device is the GPS icon is turned on when my application is running, but no data is transmitted to my Google map that's on my website where I can track where I am. Cheers Amir On Nov 4, 12:17 pm, Guillaume Perrot [EMAIL PROTECTED] wrote: Did you check if the standard map application manages to display your location ? 2008/11/4 Amir [EMAIL PROTECTED] Thanks, I'm still having issues, but now I do see the GPS 'icon' as turned on when the application is running. The issue though is that I don't get anything on the map through our online site...no longitude and latitude, or anything else. Here's the revised code I'm using: package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class LocationService extends AService { LocationManager lm = null; Location loc = null; public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); loc = lm.getLastKnownLocation(gps); if(loc == null) loc = lm.getLastKnownLocation(network); double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+,+sLongitude; //location = 40.738412973944534,-73.98468017578125; getDataMap().put(Des, OK); getDataMap().put(Value, location); } else { getDataMap().put(Des, error password!!); } new ServiceClient(this).excute(); return 0; } } On Nov 2, 8:46 am, Akbur [EMAIL PROTECTED] wrote: Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp[EMAIL PROTECTED] method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the
[android-developers] Re: Android on device GPS locate not working - code included
Thanks, I'm still having issues, but now I do see the GPS 'icon' as turned on when the application is running. The issue though is that I don't get anything on the map through our online site...no longitude and latitude, or anything else. Here's the revised code I'm using: package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class LocationService extends AService { LocationManager lm = null; Location loc = null; public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); loc = lm.getLastKnownLocation(gps); if(loc == null) loc = lm.getLastKnownLocation(network); double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+,+sLongitude; //location = 40.738412973944534,-73.98468017578125; getDataMap().put(Des, OK); getDataMap().put(Value, location); } else { getDataMap().put(Des, error password!!); } new ServiceClient(this).excute(); return 0; } } On Nov 2, 8:46 am, Akbur [EMAIL PROTECTED] wrote: Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the application/device can't find location of the android phone. please help!...below is the code I'm using for the GPS section. - Amir package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class LocationService extends AService { public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { // // location. // getDataMap().put(Des, OK); // //get location // getDataMap().put(Value, 100,100); // String location = 25,121.55; LocationManager lm = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); LocationListener locationListener = new GWLocationListener(this); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } else { getDataMap().put(Des, error password!!); } return 0; } private class GWLocationListener
[android-developers] Re: Android on device GPS locate not working - code included
Did you check if the standard map application manages to display your location ? 2008/11/4 Amir [EMAIL PROTECTED] Thanks, I'm still having issues, but now I do see the GPS 'icon' as turned on when the application is running. The issue though is that I don't get anything on the map through our online site...no longitude and latitude, or anything else. Here's the revised code I'm using: package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class LocationService extends AService { LocationManager lm = null; Location loc = null; public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); loc = lm.getLastKnownLocation(gps); if(loc == null) loc = lm.getLastKnownLocation(network); double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+,+sLongitude; //location = 40.738412973944534,-73.98468017578125; getDataMap().put(Des, OK); getDataMap().put(Value, location); } else { getDataMap().put(Des, error password!!); } new ServiceClient(this).excute(); return 0; } } On Nov 2, 8:46 am, Akbur [EMAIL PROTECTED] wrote: Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp[EMAIL PROTECTED] method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the application/device can't find location of the android phone. please help!...below is the code I'm using for the GPS section. - Amir package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class LocationService extends AService { public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { // // location. // getDataMap().put(Des, OK); // //get location // getDataMap().put(Value, 100,100); // String location = 25,121.55; LocationManager lm = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); LocationListener
[android-developers] Re: Android on device GPS locate not working - code included
Hi Guillaume, Thanks for your reply and yes the standard map application manager does display my location on the G1, but my application doesn't allow display to my website just yet. Any thoughts you may have that might help? What I see on the device is the GPS icon is turned on when my application is running, but no data is transmitted to my Google map that's on my website where I can track where I am. Cheers Amir On Nov 4, 12:17 pm, Guillaume Perrot [EMAIL PROTECTED] wrote: Did you check if the standard map application manages to display your location ? 2008/11/4 Amir [EMAIL PROTECTED] Thanks, I'm still having issues, but now I do see the GPS 'icon' as turned on when the application is running. The issue though is that I don't get anything on the map through our online site...no longitude and latitude, or anything else. Here's the revised code I'm using: package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class LocationService extends AService { LocationManager lm = null; Location loc = null; public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); loc = lm.getLastKnownLocation(gps); if(loc == null) loc = lm.getLastKnownLocation(network); double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+,+sLongitude; //location = 40.738412973944534,-73.98468017578125; getDataMap().put(Des, OK); getDataMap().put(Value, location); } else { getDataMap().put(Des, error password!!); } new ServiceClient(this).excute(); return 0; } } On Nov 2, 8:46 am, Akbur [EMAIL PROTECTED] wrote: Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp[EMAIL PROTECTED] method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the application/device can't find location of the android phone. please help!...below is the code I'm using for the GPS section. - Amir package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationListener; import
[android-developers] Re: Android on device GPS locate not working - code included
Hi Amir, Hmm... is this apps allowed permission of ACCESS_FINE_LOCATION? http://code.google.com/android/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION Keiji, Amir wrote: Hi Guillaume, Thanks for your reply and yes the standard map application manager does display my location on the G1, but my application doesn't allow display to my website just yet. Any thoughts you may have that might help? What I see on the device is the GPS icon is turned on when my application is running, but no data is transmitted to my Google map that's on my website where I can track where I am. Cheers Amir On Nov 4, 12:17 pm, Guillaume Perrot [EMAIL PROTECTED] wrote: Did you check if the standard map application manages to display your location ? 2008/11/4 Amir [EMAIL PROTECTED] Thanks, I'm still having issues, but now I do see the GPS 'icon' as turned on when the application is running. The issue though is that I don't get anything on the map through our online site...no longitude and latitude, or anything else. Here's the revised code I'm using: package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class LocationService extends AService { LocationManager lm = null; Location loc = null; public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); loc = lm.getLastKnownLocation(gps); if(loc == null) loc = lm.getLastKnownLocation(network); double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+,+sLongitude; //location = 40.738412973944534,-73.98468017578125; getDataMap().put(Des, OK); getDataMap().put(Value, location); } else { getDataMap().put(Des, error password!!); } new ServiceClient(this).excute(); return 0; } } On Nov 2, 8:46 am, Akbur [EMAIL PROTECTED] wrote: Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp[EMAIL PROTECTED] method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the
[android-developers] Re: Android on device GPS locate not working - code included
Amir, I'm sorry... permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) Keiji, Amir wrote: Hi Guillaume, Thanks for your reply and yes the standard map application manager does display my location on the G1, but my application doesn't allow display to my website just yet. Any thoughts you may have that might help? What I see on the device is the GPS icon is turned on when my application is running, but no data is transmitted to my Google map that's on my website where I can track where I am. Cheers Amir On Nov 4, 12:17 pm, Guillaume Perrot [EMAIL PROTECTED] wrote: Did you check if the standard map application manages to display your location ? 2008/11/4 Amir [EMAIL PROTECTED] Thanks, I'm still having issues, but now I do see the GPS 'icon' as turned on when the application is running. The issue though is that I don't get anything on the map through our online site...no longitude and latitude, or anything else. Here's the revised code I'm using: package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class LocationService extends AService { LocationManager lm = null; Location loc = null; public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); loc = lm.getLastKnownLocation(gps); if(loc == null) loc = lm.getLastKnownLocation(network); double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+,+sLongitude; //location = 40.738412973944534,-73.98468017578125; getDataMap().put(Des, OK); getDataMap().put(Value, location); } else { getDataMap().put(Des, error password!!); } new ServiceClient(this).excute(); return 0; } } On Nov 2, 8:46 am, Akbur [EMAIL PROTECTED] wrote: Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp[EMAIL PROTECTED] method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the application/device can't find
[android-developers] Re: Android on device GPS locate not working - code included
It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the application/device can't find location of the android phone. please help!...below is the code I'm using for the GPS section. - Amir package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class LocationService extends AService { public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { // // location. // getDataMap().put(Des, OK); // //get location // getDataMap().put(Value, 100,100); // String location = 25,121.55; LocationManager lm = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); LocationListener locationListener = new GWLocationListener(this); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } else { getDataMap().put(Des, error password!!); } return 0; } private class GWLocationListener implements LocationListener { private LocationService service; public GWLocationListener(LocationService service) { this.service=service; } @Override public void onLocationChanged(Location loc) { if (loc != null) { String location = loc.getLatitude()+,+loc.getLongitude(); service.getDataMap().put(Value, location); getDataMap().put(Des, OK); new ServiceClient(service).excute(); } else { getDataMap().put(Des, Location fail!); new ServiceClient(service).excute(); } } @Override public void onProviderDisabled(String provider) { return; } @Override public void onProviderEnabled(String provider) { return; } @Override public void onStatusChanged(String provider, int status, Bundle extras) { return; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Android on device GPS locate not working - code included
Amir, I've developed a similar app just for kicks (so the wife can keep track of me) ;) I did the following: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(gps); if (loc == null) { locType = Network; loc = lm.getLastKnownLocation(network); } In this case if the GPS service does not have a fix or is switched off, the network, though not as accurate as GPS should be active and give you an approximate location. All the best, Akbur On Nov 2, 11:45 am, Guillaume Perrot [EMAIL PROTECTED] wrote: It can take a while to the G1 to init the gps and return a fix. And you must see the sky for the GPS to work. Your code and permissions seem correct, try using the network provider to test (which is faster and work in buildings unlike the GPS). Make sure GPS location provider is enabled on the phone settings. You can check your location with the standard map application. On Nov 2, 5:42 am, C-LIS Keiji Ariyama [EMAIL PROTECTED] wrote: Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080...@c-lis.co.jp method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); }} - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the application/device can't find location of the android phone. please help!...below is the code I'm using for the GPS section. - Amir package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class LocationService extends AService { public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { // // location. // getDataMap().put(Des, OK); // //get location // getDataMap().put(Value, 100,100); // String location = 25,121.55; LocationManager lm = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); LocationListener locationListener = new GWLocationListener(this); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } else { getDataMap().put(Des, error password!!); } return 0; } private class GWLocationListener implements LocationListener { private LocationService service; public GWLocationListener(LocationService service) { this.service=service; } @Override public void onLocationChanged(Location loc) { if (loc != null) { String location = loc.getLatitude()+,+loc.getLongitude(); service.getDataMap().put(Value, location); getDataMap().put(Des, OK); new ServiceClient(service).excute(); } else { getDataMap().put(Des, Location fail!); new ServiceClient(service).excute(); } } @Override public void onProviderDisabled(String provider) { return; } @Override public void onProviderEnabled(String provider) { return; } @Override public void onStatusChanged(String provider, int status, Bundle extras) { return; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Android on device GPS locate not working - code included
Hi Amir, I had encountered a same situation. But my case is about getLastKnownLocation(String) cid:part1.07010905.08080404@c-lis.co.jp method on the emulator. In that time, I fixed my code below. Old public class TestActivity extends Activity { private void initActivity() { LocationManager locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); } } - Fixed public class TestActivity extends Activity { LocationManager locman = null; private void initActivity() { locman = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); } } - Sorry. I don't know about G1. Because I have not been having it... Keiji, Amir wrote: I'm creating a project that allows for my location to be found using the android device and communicating with my website as to where my Android device is. When I download the .apk to my phone the following permissions are acquired: Network communication (full) Your location (fine (GPS), coarse (network-based) location) As of now, on the emulator everything works fine and I can find my location (default location on Google Maps), but on the phone the application/device can't find location of the android phone. please help!...below is the code I'm using for the GPS section. - Amir package org.gw.service; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class LocationService extends AService { public int excute() { getDataMap().put(Command, LOCATION); if (isOk()) { // // location. // getDataMap().put(Des, OK); // //get location // getDataMap().put(Value, 100,100); // String location = 25,121.55; LocationManager lm = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); LocationListener locationListener = new GWLocationListener(this); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } else { getDataMap().put(Des, error password!!); } return 0; } private class GWLocationListener implements LocationListener { private LocationService service; public GWLocationListener(LocationService service) { this.service=service; } @Override public void onLocationChanged(Location loc) { if (loc != null) { String location = loc.getLatitude()+,+loc.getLongitude(); service.getDataMap().put(Value, location); getDataMap().put(Des, OK); new ServiceClient(service).excute(); } else { getDataMap().put(Des, Location fail!); new ServiceClient(service).excute(); } } @Override public void onProviderDisabled(String provider) { return; } @Override public void onProviderEnabled(String provider) { return; } @Override public void onStatusChanged(String provider, int status, Bundle extras) { return; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---