Xamarin + vs2015 Android development GPS loaction return null summary, xamarinvs2015

Source: Internet
Author: User

Xamarin + vs2015 Android development GPS loaction return null summary, xamarinvs2015

Recently, the company wants to develop android, so we have studied the GPS in Xamarin to android.

Not much nonsense, but focus on it.

To obtain gps information on a mobile phone, you must use

LocationManager

Location

You cannot grant the ACCESS_FINE_LOCATION permission to these two classes (if you want to ask where the permission is, project-property-Android Manifest)

At the beginning, I wrote all the code in an event to get the information, but it won't work after being encapsulated. I have been using baidu and google for a long time.

DDMS or Telnet is used to send location information, but I have tried it, that is, location returns null.

Later, I checked the API and found that the LocationManager and RequestLocationUpdates information must be declared at the beginning.

The Code is as follows:

LocationManager mLocationManager;

MLocationManager = GetSystemService (Context. LocationService) as LocationManager;

String Provider = LocationManager. GpsProvider;

If (mLocationManager. IsProviderEnabled (Provider ))
{
MLocationManager. RequestLocationUpdates (Provider, 2000, 1, this );
}

Otherwise, the gps icon on the simulator will not be displayed. If you use this sentence and click the position to send it, you will see the gps icon displayed on the simulator.

If you still don't understand it, you can mail me a 396116416@qq.com or I will send you the source code.

If I have written something wrong, I would like to see a lot of advice from the experts. I hope that you can avoid detours if you encounter the same problem.

Everyone makes progress together.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.