xamarin.android - How to Get GPS base on Wifi using Xamarin -


this code base on link below:
http://docs.xamarin.com/guides/android/platform_features/maps_and_location/part_3_-_location_services

i not lat/lon ( gps/wifi)

the code below :

i have added: <uses-permission android:name="android.permission.access_coarse_location" /> &lt:uses-permission android:name="android.permission.access_fine_location" />

android.locations

using system;  using android.app;  using android.content;  using android.runtime;  using android.views;  using android.widget;  using android.os;   //-- add these   using android.locations;  using system.collections.generic;  using system.threading;  using system.text;  using system.linq;  using system.xml;    namespace gpswifi  {      [activity (label = "gpswifi", mainlauncher = true)]      public class activity1 : activity     {                     int count = 1;          private locationmanager _locmgr;        protected override void oncreate (bundle bundle)     {         base.oncreate (bundle);          // set our view "main" layout resource          setcontentview (resource.layout.main);                 initializelocationmanager();            }        private void initializelocationmanager()     {          _locmgr = (locationmanager) getsystemservice(locationservice);          var locationcriteria = new criteria();          locationcriteria.accuracy = accuracy.norequirement;          locationcriteria.powerrequirement = power.norequirement;          string locationprovider = _locmgr.getbestprovider(locationcriteria, true);          _locmgr.requestlocationupdates (locationprovider, 2000, 1, this);                 }        protected override void onresume ()     {          base.onresume ();      _locmgr.requestlocationupdates (locationmanager.gpsprovider, 2000, 1, this);                  }        protected override void onpause ()     {          base.onpause ();         _locmgr.removeupdates (this);      }        public void onproviderdisabled(string provider) {}       public void onproviderenabled(string provider) {}         public void onlocationchanged (location location)     {      var locationtext = findviewbyid<textview>(resource.id.locationtextview);      locationtext.text = string.format ("latitude = {0}, longitude = {1}",                                                 location.latitude, location.longitude);           }     }  } 

your appreciated.

-- error message :

c:\program files (x86)\msbuild\xamarin\android\xamarin.android.common.targets(2,2): error msb4018: "aapt" task failed unexpectedly.

system.invalidoperationexception: sequence contains no elements

at system.linq.enumerable.first[tsource](ienumerable`1 source)

at xamarin.android.tasks.buildtoolsutils.getbuildtoolspath(string androidsdkdirectory)

at xamarin.android.tasks.aapt.generatefullpathtotool()

at microsoft.build.utilities.tooltask.computepathtotool()

at microsoft.build.utilities.tooltask.execute()

at xamarin.android.tasks.aapt.execute()

at microsoft.build.backend.taskexecutionhost.microsoft.build.backend.itaskexecutionhost.execute()

at microsoft.build.backend.taskbuilder.d__20.movenext() (msb4018) (gpswifi)

this error: the "aapt" task failed unexpectedly. has started occurring - think it's latest sdk's android/google - think they've moved file location.

check other questions xamarin studio 2 - latest stable update - error executing task aapt: source sequence empty

then check xamarin support - they'll issue update fix this.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -