locked
Location Service Enabling RRS feed

  • Question

  • Sir, I am new for Windows Mobile 8.1 app 

           Please provide code for Enabling/Showing Location services Page in Mobile(when button click event occurs)

    Wednesday, September 16, 2015 2:09 PM

Answers

  • Hi rmurali.mcp,

    You can use Geolocator.LocationStatus to validate whether location service is turned on or off in Windows Phone 8.1 app. This method returns PositionStatus, and PositionStatus.Disabled indicate that the app does not have permission to access location. More information at PositionStatus enumeration.

    And if you want to enable location services, you may provide a convenient link to the location privacy settings in the Settings app. You can refer to Step 6 in this article Detect the user's location. Notice that you need use "ms-settings-location:" in Windows Phone 8.1. 

    For example:

    In your XAML:

    <TextBlock x:Name="LocationDisabledMessage"
               Margin="0,15,0,0"
               FontStyle="Italic"
               TextWrapping="Wrap"
               Visibility="Collapsed">
        <Run Text="This app is not able to access Location. Go to " />
        <Hyperlink NavigateUri="ms-settings-location:">
            <Run Text="Settings" />
        </Hyperlink>
        <Run Text=" to check the location privacy settings." />
    </TextBlock>


    And in your code-behind:

    Geolocator geolocator = new Geolocator();
    if (geolocator.LocationStatus == PositionStatus.Disabled)
    {
        LocationDisabledMessage.Visibility = Visibility.Visible;
    }

    Hope this will be helpful for you.

    Regards,

    Jay


    Tuesday, September 29, 2015 3:20 AM

All replies

  • Hi rmurali.mcp,

    Do you mean you want some samples about how to detect user's location?

    If so you can refer to this sample: Geolocation sample. This sample shows how to detect user's location. And to display the location you can use MapControl in Windows Phone 8.1 app. For more information you can find at Detect location and Maps and location overview.

    Hope this will be helpful for you.

    Regards,

    Jay


    Thursday, September 17, 2015 2:16 AM
  • hi 

      Thanks for your response.

    I actually want to validated whether location is services is turned on/off (in first page).

    If it is in off condition i need to enable by code itself asking a confirmation from user.

    And after enabling location services,the page has to move to next page(second page)

    Can you help me? 

    Thursday, September 24, 2015 2:13 PM
  • Hi rmurali.mcp,

    You can use Geolocator.LocationStatus to validate whether location service is turned on or off in Windows Phone 8.1 app. This method returns PositionStatus, and PositionStatus.Disabled indicate that the app does not have permission to access location. More information at PositionStatus enumeration.

    And if you want to enable location services, you may provide a convenient link to the location privacy settings in the Settings app. You can refer to Step 6 in this article Detect the user's location. Notice that you need use "ms-settings-location:" in Windows Phone 8.1. 

    For example:

    In your XAML:

    <TextBlock x:Name="LocationDisabledMessage"
               Margin="0,15,0,0"
               FontStyle="Italic"
               TextWrapping="Wrap"
               Visibility="Collapsed">
        <Run Text="This app is not able to access Location. Go to " />
        <Hyperlink NavigateUri="ms-settings-location:">
            <Run Text="Settings" />
        </Hyperlink>
        <Run Text=" to check the location privacy settings." />
    </TextBlock>


    And in your code-behind:

    Geolocator geolocator = new Geolocator();
    if (geolocator.LocationStatus == PositionStatus.Disabled)
    {
        LocationDisabledMessage.Visibility = Visibility.Visible;
    }

    Hope this will be helpful for you.

    Regards,

    Jay


    Tuesday, September 29, 2015 3:20 AM
  • Thank you very much Jay Zuo
    Wednesday, September 30, 2015 5:50 AM