How to get longitude/latitude from GsmCellLocation?

2,126 views
Skip to first unread message

nguyenvuthiennga

unread,
May 7, 2010, 2:04:45 PM5/7/10
to android-platform
Hi all,

Does anyone know how get longitude/latitude from GsmCellLocation?

Thanks in advance,

Nga

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

merrou

unread,
May 7, 2010, 2:10:48 PM5/7/10
to android-...@googlegroups.com

Implement locationlistner  and use getLatitude ......

nguyenvuthiennga

unread,
May 7, 2010, 2:18:42 PM5/7/10
to android-platform
I found some websites mentioning that can be obtained by google maps
api.

I tried to get google maps api for my android source code but I don't
really know how.

http://code.google.com/android/add-ons/google-apis/maps-overview.html
This site gives some idea but mostly about application.

I want to use those APIs for the system. Does anyone know how?

Nga

On May 7, 8:10 pm, merrou <mer...@gmail.com> wrote:
> Implement locationlistner  and use getLatitude ......
>
> On May 7, 2010 8:04 PM, "nguyenvuthiennga" <nguyenvuthien...@gmail.com>
> wrote:
>
> Hi all,
>
> Does anyone know how get longitude/latitude from GsmCellLocation?
>
> Thanks in advance,
>
> Nga
>
> --
> You received this message because you are subscribed to the Google Groups
> "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> .
> For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.

merrou

unread,
May 10, 2010, 3:24:14 AM5/10/10
to android-...@googlegroups.com

Use a Google  sdk version  when you create your project ... it include a map. Jar , so you can use Google map , don't forgot also to include your map key in your layout ( search in Google ) ..... hope this will help you .....

On May 7, 2010 8:18 PM, "nguyenvuthiennga" <nguyenvu...@gmail.com> wrote:

I found some websites mentioning that can be obtained by google maps
api.

I tried to get google maps api for my android source code but I don't
really know how.

http://code.google.com/android/add-ons/google-apis/maps-overview.html
This site gives some idea but mostly about application.

I want to use those APIs for the system. Does anyone know how?

Nga

On May 7, 8:10 pm, merrou <mer...@gmail.com> wrote: > Implement locationlistner  and use getLatitud...

> On May 7, 2010 8:04 PM, "nguyenvuthiennga" <nguyenvuthien...@gmail.com>

> wrote: > > Hi all, > > Does anyone know how get longitude/latitude from GsmCellLocation? > > Thank...

> > -- > You received this message because you are subscribed to the Google Groups "android-platform...

> For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.

--

You received this message because you are subscribed to the Google Groups "android-platform" group. ...

Burcu Dogan

unread,
May 10, 2010, 4:29:09 AM5/10/10
to android-...@googlegroups.com
Hello,

I have to mention, it's not related to Google Maps API. You need to listen location changes coming from your GSM network. I'm including details below:

LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, new LocationListener(){

            @Override
            public void onLocationChanged(Location location) {
                networkLocation = new GeoPoint((int)(location.getLatitude() * 1E6), (int)(location.getLongitude() * 1E6));
               
            }

            @Override
            public void onProviderDisabled(String provider) {}

            @Override
            public void onProviderEnabled(String provider) {}

            @Override
            public void onStatusChanged(String provider, int status,
                    Bundle extras) {}});

This continuously will change networkLocation to the GSM network updates location. Take a look at requestLocationUpdates arguments for more.
I hope this helps,

Burcu Dogan


--
http://blog.burcudogan.com

nguyenvuthiennga

unread,
May 10, 2010, 11:11:54 AM5/10/10
to android-platform
Thank for all your replies!
@merrou: the problem is that I don't know how to integrate google map
into my android source. I need to know the API's name and use that API
in my new android version

@Burcu Dogan: You are talking about GPS location. But I am trying to
overcome the problem when GPS does not work. One way is to use
GsmCellLocation which provides Cell-Id and LAC(Location Area Code).
From this information, GoogleMap can give you longitude and latitude.
I just don't know which API and how to download the library.

Nga


On May 10, 10:29 am, Burcu Dogan <bu...@burcudogan.com> wrote:
> Hello,
>
> I have to mention, it's not related to Google Maps API. You need to listen
> location changes coming from your GSM network. I'm including details below:
>
> LocationManager locationManager = (LocationManager)
> context.getSystemService(Context.LOCATION_SERVICE);
> locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,
> 0, new LocationListener(){
>
>             @Override
>             public void onLocationChanged(Location location) {
>                 networkLocation = new GeoPoint((int)(location.getLatitude()
> * 1E6), (int)(location.getLongitude() * 1E6));
>
>             }
>
>             @Override
>             public void onProviderDisabled(String provider) {}
>
>             @Override
>             public void onProviderEnabled(String provider) {}
>
>             @Override
>             public void onStatusChanged(String provider, int status,
>                     Bundle extras) {}});
>
> This continuously will change networkLocation to the GSM network updates
> location. Take a look at requestLocationUpdates arguments for more.
> I hope this helps,
>
> Burcu Dogan
>
> --http://blog.burcudogan.com
>
>
>
> On Mon, May 10, 2010 at 10:24 AM, merrou <mer...@gmail.com> wrote:
> > Use a Google  sdk version  when you create your project ... it include a
> > map. Jar , so you can use Google map , don't forgot also to include your map
> > key in your layout ( search in Google ) ..... hope this will help you .....
>
> > On May 7, 2010 8:18 PM, "nguyenvuthiennga" <nguyenvuthien...@gmail.com>
> > wrote:
>
> > I found some websites mentioning that can be obtained by google maps
> > api.
>
> > I tried to get google maps api for my android source code but I don't
> > really know how.
>
> >http://code.google.com/android/add-ons/google-apis/maps-overview.html
> > This site gives some idea but mostly about application.
>
> > I want to use those APIs for the system. Does anyone know how?
>
> > Nga
>
> > On May 7, 8:10 pm, merrou <mer...@gmail.com> wrote: > Implement
> > locationlistner  and use getLatitud...
> > > On May 7, 2010 8:04 PM, "nguyenvuthiennga" <nguyenvuthien...@gmail.com>
>
> > > wrote: > > Hi all, > > Does anyone know how get longitude/latitude from
> > GsmCellLocation? > > Thank...
> > > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > <android-platform%2Bunsu...@googlegroups.com<android-platform%252Buns...@googlegroups.com>
>
> > > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/android-platform?hl=en.
>
> > > > -- > You received this message because you are subscribed to the Google
> > Groups "android-platform...
> > > For more options, visit this group athttp://
> > groups.google.com/group/android-platform?hl=en.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "android-platform" group. ...
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "android-platform" group.
> > To post to this group, send email to android-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-platform?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.

--
You received this message because you are subscribed to the Google Groups "android-platform" group.

Ne0

unread,
May 10, 2010, 11:33:10 AM5/10/10
to android-platform
I dont think you read Burcu Dogan's reply properly, there is a
NetworkLocationProvider that provides GPS co-ordinates from google
servers without the need for GPS. This does not use the Maps API.

Saying this for different reason i want to build a MapActivity as a
system app in a custom build of android, does anyone know how i can
add the map jar to the source tree so i can do this?

Ne0

Burcu Dogan

unread,
May 10, 2010, 1:00:53 PM5/10/10
to android-...@googlegroups.com
Hi again,

I'm listening the LocationManager.NETWORK_PROVIDER, not the GPS one. This will automatically return location updates based on your connection.

Thanks,
Burcu Dogan
--
http://blog.burcudogan.com

nguyenvuthiennga

unread,
May 11, 2010, 4:22:20 AM5/11/10
to android-platform
Hi Burcu Dogan,

Thanks for clarification.

I tried to use NETWORK_PROVIDER but I got the following exception


05-11 10:15:18.727: ERROR/LocationManagerService(66): requestUpdates
got exception:
05-11 10:15:18.727: ERROR/LocationManagerService(66):
java.lang.IllegalArgumentException: provider=network
05-11 10:15:18.727: ERROR/LocationManagerService(66): at
com.android.server.LocationManagerService.requestLocationUpdatesLocked(LocationManagerService.java:
964)
05-11 10:15:18.727: ERROR/LocationManagerService(66): at
com.android.server.LocationManagerService.requestLocationUpdates(LocationManagerService.java:
934)
05-11 10:15:18.727: ERROR/LocationManagerService(66): at
android.location.ILocationManager
$Stub.onTransact(ILocationManager.java:89)
05-11 10:15:18.727: ERROR/LocationManagerService(66): at
android.os.Binder.execTransact(Binder.java:287)
05-11 10:15:18.727: ERROR/LocationManagerService(66): at
dalvik.system.NativeStart.run(Native Method)


Can you please help me out?

Thanks in advance,

Nga
> > > > > <android-platform%2Bunsu...@googlegroups.com<android-platform%252Buns...@googlegroups.com>
> > <android-platform%252Buns...@googlegroups.com<android-platform%25252Bun...@googlegroups.com>
>
> > > > > > .
> > > > > > For more options, visit this group athttp://
> > > > > groups.google.com/group/android-platform?hl=en.
>
> > > > > > > -- > You received this message because you are subscribed to the
> > Google
> > > > > Groups "android-platform...
> > > > > > For more options, visit this group athttp://
> > > > > groups.google.com/group/android-platform?hl=en.
>
> > > > > --
>
> > > > > You received this message because you are subscribed to the Google
> > Groups
> > > > > "android-platform" group. ...
>
> > > > >  --
> > > > > You received this message because you are subscribed to the Google
> > Groups
> > > > > "android-platform" group.
> > > > > To post to this group, send email to
> > android-...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > <android-platform%2Bunsu...@googlegroups.com<android-platform%252Buns...@googlegroups.com>
>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-platform?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups "android-platform" group.
> > > > To post to this group, send email to android-...@googlegroups.com
> > .
> > > > To unsubscribe from this group, send email to
> > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/android-platform?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "android-platform" group.
> > > To post to this group, send email to android-...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/android-platform?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-platform" group.
> > To post to this group, send email to android-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-platform?hl=en.
>
> --http://blog.burcudogan.com
>
> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.

nguyenvuthiennga

unread,
May 20, 2010, 11:36:36 PM5/20/10
to android-platform
I tried to search and it seems that people can use NETWORK_PROVIDER. I
even tried in the phone (not emulator) but still get exception:
java.lang.IllegalArgumentException: provider=network!!!

Does anyone know how to use NETWORK_PROVIDER?


On May 11, 10:22 am, nguyenvuthiennga <nguyenvuthien...@gmail.com>
wrote:
> Hi Burcu Dogan,
>
> Thanks for clarification.
>
> I tried to useNETWORK_PROVIDERbut I got the following exception

Burcu Dogan

unread,
May 21, 2010, 1:48:43 AM5/21/10
to android-...@googlegroups.com
Hello again,

What's the version of your target SDK?

Cheers,
Burcu Dogan
--

nguyenvuthiennga

unread,
May 21, 2010, 4:28:15 AM5/21/10
to android-platform
Hi,

I am using Android source code 1.6 (cupcake).

So you meant network_provider may be not supported in this version?

Nga

On May 21, 7:48 am, Burcu Dogan <bu...@burcudogan.com> wrote:
> Hello again,
>
> What's the version of your target SDK?
>
> Cheers,
> Burcu Dogan
>
> On Fri, May 21, 2010 at 6:36 AM, nguyenvuthiennga <
>
> > > > > > > > <android-platform%2Bunsu...@googlegroups.com<android-platform%252Buns...@googlegroups.com>
> > <android-platform%252Buns...@googlegroups.com<android-platform%25252Bun...@googlegroups.com>
>
> > > > > <android-platform%252Buns...@googlegroups.com<android-platform%25252Bun...@googlegroups.com>
> > <android-platform%25252Bun...@googlegroups.com<android-platform%2525252Bu...@googlegroups.com>
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/android-platform?hl=en.
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > Groups "android-platform" group.
> > > > > > > To post to this group, send email to
> > android-...@googlegroups.com
> > > > > .
> > > > > > > To unsubscribe from this group, send email to
> > > > > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > <android-platform%2Bunsu...@googlegroups.com<android-platform%252Buns...@googlegroups.com>
>
> > > > > .
> > > > > > > For more options, visit this group athttp://
> > > > > groups.google.com/group/android-platform?hl=en.
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > Groups
> > > > > "android-platform" group.
> > > > > > To post to this group, send email to
> > android-...@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > <android-platform%2Bunsu...@googlegroups.com<android-platform%252Buns...@googlegroups.com>
>
> > > > > .
> > > > > > For more options, visit this group athttp://
> > > > > groups.google.com/group/android-platform?hl=en.
>
> > > > > --
> > > > > You
>
> ...
>
> read more »

nguyenvuthiennga

unread,
May 21, 2010, 4:33:28 AM5/21/10
to android-platform
Sorry.

I am using Android source code 1.6 (donut).

Nga

On May 21, 10:28 am, nguyenvuthiennga <nguyenvuthien...@gmail.com>
wrote:

nguyenvuthiennga

unread,
May 21, 2010, 8:23:11 AM5/21/10
to android-platform
I read the code of LocationManagerService. While loading provider,
they load only GPS Provider but not Network Provider.

// Attempt to load "real" providers first
if (GpsLocationProvider.isSupported()) {
// Create a gps location provider
GpsLocationProvider provider = new
GpsLocationProvider(mContext, this);
mGpsStatusProvider = provider.getGpsStatusProvider();
LocationProviderProxy proxy = new
LocationProviderProxy(LocationManager.GPS_PROVIDER, provider);
addProvider(proxy);
mGpsLocationProvider = proxy;
}

updateProvidersLocked();


Is that the problem? What should I do to get network provider work?


On May 21, 10:33 am, nguyenvuthiennga <nguyenvuthien...@gmail.com>
wrote:

Ne0

unread,
May 21, 2010, 8:38:13 AM5/21/10
to android-platform
Hi,

The NetworkLocation.apk is NOT open source, hence the open source code
does not load it. The NetworkLocation package subscribes to be a
provider, i would be very surprised if you will get a device that does
not have this on it. If you are using the emulator then you will not
be able to test you network location code. I personally dont use it,
but i just checked the install NOTICE of the emulator images and it
confirms that NetworkLocation.apk is not part of it. The code in the
5th post works and receives updates on all devices that have the
NetworkLocation.apk installed.

If you are having problems, post your code and i will help where i
can.

Ne0


On May 21, 1:23 pm, nguyenvuthiennga <nguyenvuthien...@gmail.com>
wrote:

nguyenvuthiennga

unread,
May 21, 2010, 8:48:34 AM5/21/10
to android-platform
Hi,

Thanks a lot.

I have a google io device and I downloaded source code of Android 1.6.
I tried to modify something in the source code and flash on my phone.

That may delete the old version in my phone. And you explained me that
NetworkLocation.apk is not included in the code. That's why it didn't
work in my phone.

Do you know where I can download the apk and put it in my phone?

Thanks,

Nga

Liam Alford

unread,
May 21, 2010, 9:22:00 AM5/21/10
to android-...@googlegroups.com
Yeah, if you want you can "test" your own build of android by flashing your device with the original i/o device img and pulling the NetworkLocation.apk using adb.

Once you have it, put it in the mydroid->out->target->product->your-device->system->app folder, delete any system.img files from the out directory tree (there will be at least 2) then rebuild, and flash your img. You should find that NetworkLocatio.apk is installed. (if you do a clean build though, it will delete your NetworkLocation.apk)

Alternatively, if you device is rooted, get the NetworkLocation.apk from a custom ROM (MoDaCo) and push it to /system/app/ on your device. You may run into signature issues doing it that way though, but it should work if your own build is signed with the testkeys from the open source project.

Hope it helps,

Ne0

nguyenvuthiennga

unread,
May 21, 2010, 11:43:30 AM5/21/10
to android-platform
Hi,

Thanks a lot.

I tried to follow your instruction (put NetworkLocation.apk in /out/
target/product/sapphire-open/system/app/). Compiling has no error but
booting does not succeed. It has some errors like:

05-21 17:30:55.023: ERROR/AndroidRuntime(271):
java.lang.RuntimeException: Unable to instantiate receiver
com.google.android.location.BootCompletedReceiver:
java.lang.ClassNotFoundException:
com.google.android.location.BootCompletedReceiver in loader
dalvik.system.PathClassLoader@4386b8a8


And then the phone auto reboots.

I also tried adb install but then the error is INSTALL_FAILED_DEXOPT

I really don't what to do next!!!

Can anyone help me out?

Nga
On May 21, 3:22 pm, Liam Alford <liamjamesalf...@googlemail.com>
wrote:
> Yeah, if you want you can "test" your own build of android by flashing your
> device with the original i/o device img and pulling the NetworkLocation.apk
> using adb.
>
> Once you have it, put it in the
> mydroid->out->target->product->*your-device*->system->app
> folder, delete any system.img files from the out directory tree (there will
> be at least 2) then rebuild, and flash your img. You should find that
> NetworkLocatio.apk is installed. (if you do a clean build though, it will
> delete your NetworkLocation.apk)
>
> Alternatively, if you device is rooted, get the NetworkLocation.apk from a
> custom ROM (MoDaCo <http://www.MoDaCo.com>) and push it to /system/app/ on
> your device. You may run into signature issues doing it that way though, but
> it should work if your own build is signed with the testkeys from the open
> source project.
>
> Hope it helps,
>
> Ne0
>
> On Fri, May 21, 2010 at 1:48 PM, nguyenvuthiennga <
>

Liam Alford

unread,
Jun 9, 2010, 1:00:11 PM6/9/10
to android-...@googlegroups.com

Ah yes, you will be missing the Google libraries, you can do a similar thing by copying the libraries from /system/framework on the original rom and then putting them in the out/target/......system/framework folder. Only copy the Google ones that are not there when u normally build the code. Hope that makes sense. You may have figured this out already, sorry for the late response.

On 21 May 2010 16:43, "nguyenvuthiennga" <nguyenvu...@gmail.com> wrote:

Hi,

Thanks a lot.

I tried to follow your instruction (put NetworkLocation.apk in /out/
target/product/sapphire-open/system/app/). Compiling has no error but
booting does not succeed. It has some errors like:

05-21 17:30:55.023: ERROR/AndroidRuntime(271):
java.lang.RuntimeException: Unable to instantiate receiver
com.google.android.location.BootCompletedReceiver:
java.lang.ClassNotFoundException:
com.google.android.location.BootCompletedReceiver in loader
dalvik.system.PathClassLoader@4386b8a8


And then the phone auto reboots.

I also tried adb install but then the error is INSTALL_FAILED_DEXOPT

I really don't what to do next!!!

Can anyone help me out?

Nga
On May 21, 3:22 pm, Liam Alford <liamjamesalf...@googlemail.com>
wrote:

> Yeah, if you want you can "test" your own build of android by flashing your

> device with the orig...

> custom ROM (MoDaCo <http://www.MoDaCo.com>) and push it to /system/app/ on

> your device. You may run into signature issues doing it that way though, but

> it should work if y...

> nguyenvuthien...@gmail.com> wrote:
> > Hi,
>
> > Thanks a lot.
>

> > I have a google io device and...

> ...
>
> read more »

--
You received this message because you are subscribed to the Google Groups...

Reply all
Reply to author
Forward
0 new messages