public async static void Register()
        {
            if (!IsTaskRegistered())
            {
                try
                {
                    BackgroundAccessStatus backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync();

                    doRegist();
                    switch (backgroundAccessStatus)
                    {
                    case BackgroundAccessStatus.Unspecified:
                    case BackgroundAccessStatus.Denied:
                        MessageDialogWithLanguage.showDialog("必须将该应用添加到锁屏,后台任务才能正常运行!", "You must add this app to lock screen so that the background task can run normally!");
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception e)
                {
                    if (e.HResult == -2147024846)
                    {
                        MessageDialogWithLanguage.showDialog("模拟器不支持后台任务,请使用本地计算机或远程计算机!", "The simulator doesn't support background task. Please try again using local computer or remote computer!");
                    }
                }
            }
        }
 private void showMessage()
 {
     if (!hasShow)
     {
         hasShow = true;
         MessageDialogWithLanguage.showDialog("定位功能没有开启,这将导致应用的定位和地理围栏功能不可用,请通过系统设置开启定位功能!", "The device's location function is not open, this will cause the location and geofence function of this app is not available. Please open through the system setting!");
     }
 }
Exemplo n.º 3
0
        //创建geofence按钮响应事件
        private void btn_create_Click(object sender, RoutedEventArgs e)
        {
            string name = txb_identifier.Text;
            double lat;
            double longit;
            double radius;

            if (name == "")
            {
                MessageDialogWithLanguage.showDialog("请输入名称", "Please input the name!");
                return;
            }
            if (!(Double.TryParse(txb_latitude.Text, out lat) && Double.TryParse(txb_longitude.Text, out longit) && Double.TryParse(txb_radius.Text, out radius)))
            {
                MessageDialogWithLanguage.showDialog("数据格式不正确", "The data format is not correct");
                return;
            }
            if (lat < 0 || lat > 90)
            {
                MessageDialogWithLanguage.showDialog("纬度超出范围,应在0-90之间!", "Latitude out of scope, should be between 0-90!");
                return;
            }
            if (longit > 180 || longit < -180)
            {
                MessageDialogWithLanguage.showDialog("经度超出范围,应在-180-180之间!", "Longitude out of scope, should be between -180-180!");
                return;
            }
            if (GeofenceManager.Instance.CreateGeofence(name, lat, longit, radius, async(geofence, newState) =>
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => stateChangedCallback(geofence, newState));
            }))
            {
                MessageDialogWithLanguage.showDialog("创建成功", "Create success!");
                GoBack();
            }
            else
            {
                MessageDialogWithLanguage.showDialog("该名称已存在,请尝试其他名称!", "This name has been used. Please try with anthor name!");
            }
        }