5,597,707 Members 34,479 Now Online
XDA Developers Android and Mobile Development Forum
View Poll Results: Should I Integrate GPS Support into the DLL??
Yes 38 97.44%
No 1 2.56%
Voters: 39. You may not vote on this poll

[.Net DLL] WMLocationInfo - Get your location via CellID/GPS the easy way!

Tip us?
 
DavidTiger
Old
(Last edited by DavidTiger; 4th February 2011 at 12:46 PM.)
#1  
Senior Member - OP
Thanks Meter 39
Posts: 199
Join Date: Nov 2008
Location: Kirkcaldy

 
DONATE TO ME
Default [.Net DLL] WMLocationInfo - Get your location via CellID/GPS the easy way!

[01/2/11] Update v2.1 - Downgraded .net to v2.0 - Should now work with VS2005!
[31/1/11] Update v2 - Now includes GPS Support!
[30/1/11] Update v1 - Initial Release - CellID Only!

I have created this DLL to allow developers to quickly and easily add support for locations. By using CellID and now GPS!

CellID: This way is done by getting looking at the Cell Towers your mobile is connected to.. and then by searching a database of Cell Locations you can work out an approximate location for your Device, Which is usually accurate within 50-100m!

GPS: I'm sure we all know what GPS is and how it works Instead of using the Cell Tower location to find your location, It takes the co-ordinates from the GPS to then query an online source to figure out your location, Which is as accurate as GPS can get! If you're outside and not blocked by many buildings it should be as accurate as <5m

To download see the attachments 'WMLocationInfo.rar' contains the DLL file only..
If you are unsure how to go about using this DLL, I have included a sample C# application with full source code, This will show you how to get location by both CellID and GPS

Please take note of the copyright info below, before downloading and using my DLL and/or Source Codes

Thanks,
-David!

Copyright 2011 David Bell / DavidTiger All Rights Reserved.
All Source Code, Compiled exe and DLL files are the copyrighted works of David Bell/DavidTiger.
You may use/redistribute any included samples or files, but you MUST leave credits where due.
You may NOT include this DLL and/or use its function in any commercial products with an intend to make a profit without written permission first!
All compiled DLL/EXE which do not include a source code have been obfuscated
You also may NOT attempt to dissasemble or reverse engineer any compiled obfuscated distributables (exe/dll).
Attached Files
File Type: rar WMLocationInfo.rar - [Click for QR Code] (9.6 KB, 501 views)
File Type: rar C# Example Project.rar - [Click for QR Code] (74.1 KB, 428 views)
File Type: rar VB Example Project.rar - [Click for QR Code] (94.9 KB, 260 views)
Phone: Sony Xperia S - Unlocked Bootloader
ROM: SlimBean 4.2.2 Weekly.6.5
Kernel: SlimBean Kernel
The Following 4 Users Say Thank You to DavidTiger For This Useful Post: [ Click to Expand ]
 
DavidTiger
Old
(Last edited by DavidTiger; 31st January 2011 at 08:28 PM.)
#2  
Senior Member - OP
Thanks Meter 39
Posts: 199
Join Date: Nov 2008
Location: Kirkcaldy

 
DONATE TO ME
-Included Sample Project in post #1-
Phone: Sony Xperia S - Unlocked Bootloader
ROM: SlimBean 4.2.2 Weekly.6.5
Kernel: SlimBean Kernel
 
oldsap
Old
#3  
oldsap's Avatar
Senior Member
Thanks Meter 10
Posts: 1,092
Join Date: Apr 2006
hi thanks for the dll file. this is my code in VB:

Code:
    'Setup variables needed throughout the source
    Dim lat As String, lon As String = ""
    Dim street As String, town As String, county As String = ""
    Dim cellid As String, lac As String, mcc As String, mnc As String = ""

    Private Sub GetCellId()
        'Retreive cell tower info from the DLL
        Dim CellTowerInfo As WMCellInfo.CellIDInfo.RILCELLTOWERINFO =   WMCellInfo.CellIDInfo.GetCellTowerInfo()

        'Asign each variable with its cell data
        cellid = CellTowerInfo.CellID.ToString()
        lac = CellTowerInfo.LAC.ToString()
        mcc = CellTowerInfo.MCC.ToString()
        mnc = CellTowerInfo.MNC.ToString()
    End Sub
    Private Sub GetCoord()
        'setup args with cellid data
        Dim args As String() = {mcc, mnc, lac, cellid}

        'call DLL to get coords and then split them.
        Dim latlng As String() = WMCellInfo.CoordinateInfo.GetLatLng(args).Split("|"c)

        'assign them to their variables.
        lat = latlng(0).ToString()
        lon = latlng(1).ToString()
    End Sub
    Private Sub GetLoc()
        'Call DLL to find location, with lat, lon parameters.
        WMCellInfo.LocationInfo.Getlocation(lat, lon)

        'Assign them into their variables.
        street = WMCellInfo.LocationInfo.locations(0)
        town = WMCellInfo.LocationInfo.locations(1)
        county = WMCellInfo.LocationInfo.locations(2)
    End Sub

   Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
        GetCellId()
      
        Label1.Text = lac & vbCrLf & mcc & vbCrLf & mnc
    End Sub
when i click on Menu_Item3, the app hangs. is there an error in my code?
http://oldsap.blogspot.com

SpeakerPhone Auto ON - Automatically turn on your speakerphone
OS Profiler - Volume Profile Scheduler.
DontSleep Wifi - will automatically turn on your wifi while preventing your device from going into sleep mode.
OS Logger - Log your SMS on your Calendar
i780 Flashing Guide
CNitrogen - Titanium Plugin for Nitrogen Music Player
SMSer - send multiple sms to multiple contacts
 
DavidTiger
Old
#4  
Senior Member - OP
Thanks Meter 39
Posts: 199
Join Date: Nov 2008
Location: Kirkcaldy

 
DONATE TO ME
Have you added "Imports WMCellInfo" at the very top of the code??
also
Added reference to the DLL??

other than that the code looks fine..
Phone: Sony Xperia S - Unlocked Bootloader
ROM: SlimBean 4.2.2 Weekly.6.5
Kernel: SlimBean Kernel
 
glaucos
Old
#5  
glaucos's Avatar
Senior Member
Thanks Meter 1
Posts: 277
Join Date: Jan 2007
Location: Torino
I'm not a developer, but... I think I'll have to thank you for a future software that will use your dll
 
DavidTiger
Old
#6  
Senior Member - OP
Thanks Meter 39
Posts: 199
Join Date: Nov 2008
Location: Kirkcaldy

 
DONATE TO ME
Thanks

Update!!
Now includes everything you need for getting your location via CellID AND GPS!!

GPS Has slightly more code to be able to use it in your project but it is necessary to use GPS

I have included a C# sample of using the DLL to get the location with CellID and GPS
I will also include a VB code sample in the next few days as soon as I have time to write it

You'll find all this in the 1st post as soon as I upload it

-David
Phone: Sony Xperia S - Unlocked Bootloader
ROM: SlimBean 4.2.2 Weekly.6.5
Kernel: SlimBean Kernel
 
oldsap
Old
#7  
oldsap's Avatar
Senior Member
Thanks Meter 10
Posts: 1,092
Join Date: Apr 2006
Hi david, i tried your sample code on my TD2 WM6.5 and it works. But when i use my own code:
Code:
Imports WMLocationInfo
Imports System
Imports System.IO
Imports System.Net
Imports System.Windows.Forms
Imports System.Text
Public Class Form1
    'Setup variables needed throughout the source
    Dim cellid As String, lac As String, mcc As String, mnc As String = Nothing

    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
        Application.Exit()
    End Sub
    Public Sub GetCellID()
        'Retreive cell tower info from the DLL
        Dim CellTowerInfo As WMLocationInfo.CellIDInfo.RILCELLTOWERINFO = WMLocationInfo.CellIDInfo.GetCellTowerInfo()

        'Asign each variable with its cell data
        cellid = CellTowerInfo.CellID.ToString()
        lac = CellTowerInfo.LAC.ToString()
        mcc = CellTowerInfo.MCC.ToString()
        mnc = CellTowerInfo.MNC.ToString()

        'Show the data on the form with labels or other controls...
        Label1.Text = "CellID = " & cellid
        Label2.Text = "LAC = " & lac
        Label3.Text = "MCC = " & mcc
        Label4.Text = "MNC = " & mnc
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GetCellID()
    End Sub

End Class
it just hangs.
http://oldsap.blogspot.com

SpeakerPhone Auto ON - Automatically turn on your speakerphone
OS Profiler - Volume Profile Scheduler.
DontSleep Wifi - will automatically turn on your wifi while preventing your device from going into sleep mode.
OS Logger - Log your SMS on your Calendar
i780 Flashing Guide
CNitrogen - Titanium Plugin for Nitrogen Music Player
SMSer - send multiple sms to multiple contacts
 
DavidTiger
Old
#8  
Senior Member - OP
Thanks Meter 39
Posts: 199
Join Date: Nov 2008
Location: Kirkcaldy

 
DONATE TO ME
I just tested your code, copied and pasted without editing, added reference to the DLL and it works great :/

See my attached images to add reference to the DLL correctly, if you haven't already
I also attached the VB project I made with your code..
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	229
Size:	17.7 KB
ID:	505598   Click image for larger version

Name:	2.png
Views:	208
Size:	19.7 KB
ID:	505599   Click image for larger version

Name:	3.jpg
Views:	171
Size:	31.3 KB
ID:	505600  
Attached Files
File Type: rar YourCode.rar - [Click for QR Code] (94.8 KB, 75 views)
Phone: Sony Xperia S - Unlocked Bootloader
ROM: SlimBean 4.2.2 Weekly.6.5
Kernel: SlimBean Kernel
 
oldsap
Old
#9  
oldsap's Avatar
Senior Member
Thanks Meter 10
Posts: 1,092
Join Date: Apr 2006
Hi David, i think i found the culprit. i'm coding using DotNetv2.0 instead of 3.5
How do i integrate 3.5 to my Visual Studio 2005?
http://oldsap.blogspot.com

SpeakerPhone Auto ON - Automatically turn on your speakerphone
OS Profiler - Volume Profile Scheduler.
DontSleep Wifi - will automatically turn on your wifi while preventing your device from going into sleep mode.
OS Logger - Log your SMS on your Calendar
i780 Flashing Guide
CNitrogen - Titanium Plugin for Nitrogen Music Player
SMSer - send multiple sms to multiple contacts
 
DavidTiger
Old
#10  
Senior Member - OP
Thanks Meter 39
Posts: 199
Join Date: Nov 2008
Location: Kirkcaldy

 
DONATE TO ME
Quote:
Originally Posted by oldsap View Post
Hi David, i think i found the culprit. i'm coding using DotNetv2.0 instead of 3.5
How do i integrate 3.5 to my Visual Studio 2005?
You cant im afraid. 3.5 is only available to VS2008 and above.
I'll try compiling the dll under v2.0 tomorrow as it does work I used the same code for my app in vs2005 before upgrading to 2008 with .net 3.5.
I think its because the dll is built under 3.5 their is not backward compatable but building it under v2.0 means it should work for both v2.0 and v3.5

I'll try it in the morning and post back if it works, then update the dll if it does

cheers,
-David
Phone: Sony Xperia S - Unlocked Bootloader
ROM: SlimBean 4.2.2 Weekly.6.5
Kernel: SlimBean Kernel

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Polish Your Custom Themes with Theme Debugger

Creating a custom Android theme from scratch can be quite the laborious task. In addition to … more

Clean Up Your Logcat Code with Lib Cleaner

Some of you may think that writing code is the hardest part of development. It’s not, as the … more

Tweak Your Xperia Device’s Camera App Yourself

We’ve come to expect nearly perfect cameraperformancein our modern day … more