Tag: windows phone 8.1

App打开时PUSH不显示

应用程序关闭时,我的应用程序会很好地接收推送通知 但是当应用程序运行时,我什么都没得到。 这与我以前在没有任何问题的应用程序中使用的代码相同,这些代码在WindowsPhone8上,而新的应用程序在WindowsPhone8.1设备上运行。 我在创建原始应用程序时使用了这个Push Tutorial 。 如果您想在应用程序打开时接收通知,我确实有一行说明添加此项。 如果8.1更新已经对推送通知做了一些很好的了解。 其他任何东西也将不胜感激。 HttpNotificationChannel pushChannel; string channelName = “PushChannel”; pushChannel = HttpNotificationChannel.Find(channelName); //Push Notifications if (pushChannel == null) { pushChannel = new HttpNotificationChannel(channelName); //// Register for all the events before attempting to open the channel. pushChannel.ChannelUriUpdated += new EventHandler( PushChannel_ChannelUriUpdated); pushChannel.ErrorOccurred += new EventHandler( PushChannel_ErrorOccurred); // Register for this […]

C#中的地理位置

我正在尝试开发一个应该像游戏一样的应用程序。 用户在城市中会有一些位置,他必须在每个位置做一些事情。 为了跟踪用户的位置,我尝试使用以下代码进行地理定位: Geolocator geolocator = new Geolocator(); //geolocator.DesiredAccuracy = Windows.Devices.Geolocation.PositionAccuracy.High; geolocator.DesiredAccuracyInMeters = 50; try { Geoposition geoposition = await geolocator.GetGeopositionAsync(TimeSpan.FromMilliseconds(500), TimeSpan.FromSeconds(1)); textLatitude.Text = “Latitude: ” + geoposition.Coordinate.Latitude.ToString(“0.0000000000”); textLongitude.Text = “Longitude: ” + geoposition.Coordinate.Longitude.ToString(“0.0000000000”); textAccuracy.Text = “Accuracy: ” + geoposition.Coordinate.Accuracy.ToString(“0.0000000000”); } 使用以下方法获取坐标,我试图测试设备是否将使用以下代码正确定位我的位置: if( Math.Abs(geoposition.Coordinate.Latitude – 45.3285) < 0.001 ){ if (Math.Abs(geoposition.Coordinate.Longitude – 14.4474) < 0.001) […]

在Windows Phone 8.1中将IBuffer转换为字节数组,怎么做?

我正在为Windows Phone 8.1编写一个应用程序。 我需要将UIElement保存为图像文件(我更喜欢JPG或PNG)。 我正在使用RenderTargetBitmap类来执行此操作。 在我的UIElement上调用RenderAsync方法之后,我创建了一个IBuffer,它包含RenderTargetBitmap方法GetPixelsAsync()的结果。 现在我需要调用方法ToArray()来转换我的IBuffer在一个字节数组中使用类似BitmapEncoder保存我的图像,但似乎在Windows Phone 8.1上没有任何ToArray()方法用于IBuffer,而在Windows上8.1存在。 我该如何解决这个问题? 谢谢!

如何检查Windows Phone 8应用程序中的Internet连接可用性

我正在开发Windows Phone 8应用程序 。 在这个应用程序中,我必须连接到服务器以获取数据。 所以在连接到服务器之前,我想检查互联网连接是否可用于设备。 如果互联网连接可用,那么我只会从服务器获取数据,否则我将显示错误消息。 请告诉我如何在Windows Phone 8中执行此操作。

使用Bouncy Castle AES / CBC / PKCS7加密字符串

我一直在寻找一些关于如何使用Bouncy Castle Framework加密标题中加密的简单字符串的示例代码。 此代码将在Windows Universal项目上运行。 我之前尝试使用内置API加密的尝试无法在服务器上解密。 我试过这个:这给了我一个字符串: 4pQUfomwVVsl68oQqWoWYNRmRM + CP + vNFXBNdkN6dZPQ34VZ35vsKn9Q7QGTDVOj + w5mqVYHnGuAOFOgdgl8kA == s = String.Format(“{0}_{1}”, s, DateTime.Now.ToString(“ddMMyyyyHmmss”)); SymmetricKeyAlgorithmProvider algorithm = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.AesCbcPkcs7); IBuffer keymaterial = CryptographicBuffer.ConvertStringToBinary(“[Key]”, BinaryStringEncoding.Utf8); CryptographicKey KEY = algorithm.CreateSymmetricKey(keymaterial); IBuffer IV = CryptographicBuffer.ConvertStringToBinary(“[IV]”, BinaryStringEncoding.Utf8); IBuffer data = CryptographicBuffer.ConvertStringToBinary(s, BinaryStringEncoding.Utf8); IBuffer output = CryptographicEngine.Encrypt(KEY, data, IV); return CryptographicBuffer.EncodeToBase64String(output); 服务器使用加密/解密 public static string […]

在Windows Phone 8.1共享合同中显示Viber,Whatsup

嗨,我正在开发一个在Windows Phone 8.1中通过共享合同共享图片的应用程序。 我的代码是 DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += new TypedEventHandler(this.DataRequested); 和 private async void DataRequested(DataTransferManager sender, DataRequestedEventArgs args) { DataRequest request = args.Request; request.Data.Properties.Title = “Unscramble this”; request.Data.Properties.Description = “”; request.Data.SetText(string.Format(“Scrambled word is {0} and clue is {1}. Help me to unscramble this \r\n(via Unscramble Plus for Windows Phone)”,scrambledString.ToUpper(),selectedMeanings.ToUpper())); DataRequestDeferral deferral = request.GetDeferral(); […]

在滚动结束时使用LoadMoreItemsAsync创建ListView

我在Windows Phone 8.1应用程序中有一个ListView ,我可以有1000个或更多的结果,所以每次滚动到底时我需要实现一个Load Morefunction,或者一些其他逻辑和自然方式触发添加更多列表中的项目。 我发现ListView支持ISupportIncrementalLoading ,并发现了这个实现: https : //marcominerva.wordpress.com/2013/05/22/implementing-the-isupportincrementalloading-interface-in-a-window-store-app/这是我找到的更好的解决方案,因为它没有指定类型,即它是通用的。 我对此解决方案的问题是,当ListView被加载时, LoadMoreItemsAsync运行所需的所有时间,直到获得所有结果,这意味着用户不会触发加载更多。 我不确定是什么使得LoadMoreItemsAsync触发器,但是有些东西是不对的,因为它假设当我打开页面并在现场加载所有项目时,没有我做任何事情或任何滚动。 这是实施: IncrementalLoadingCollection.cs public interface IIncrementalSource { Task<IEnumerable> GetPagedItems(int pageIndex, int pageSize); void SetType(int type); } public class IncrementalLoadingCollection : ObservableCollection, ISupportIncrementalLoading where T : IIncrementalSource, new() { private T source; private int itemsPerPage; private bool hasMoreItems; private int currentPage; public IncrementalLoadingCollection(int type, […]

Windows 8.1中的http客户端取消请求

我正在开发Windows Phone 8.1项目。 Windows 8.1中有两个版本的http客户端system.net.http和windows.web.http 。 Microsoft建议使用更高版本。 所以,我决定坚持下去。 但我无法找到一种方法来取消使用windows.web.http.httpclient启动的Web请求。 在system.net.http.httpclient有一个CancelPendingRequests方法,但后面的选项不存在类似的方法。 那么,是否有可能取消网络请求,如果是这样的话? 示例代码: 考虑一个Http Get请求谷歌如下。 如果用户愿意,我想在完成之前取消它。 // Windows Phone 8.1 project (not silverlight) public sealed partial class MainPage : Page { Windows.Web.Http.HttpClient client = new Windows.Web.Http.HttpClient(); public MainPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Required; Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, e) => { CancelGet(); } } private void CancelGet() { […]

用波浪动画填充椭圆

我已经在Windows Phone 8.1 Silverlight App和UWP中创建了一个椭圆,我想用动画波填充它,为此,我正在遵循这个解决方案 但它适用于WPF,所以我无法使用像“Visual Brush”这样的控件。 我想用类似于此的波填充椭圆(在图像中忽略50%) – 这是我的eliipse 视觉刷上的任何替代品? 主要是我想在Windows Phone 8.1 Silverlight中实现它,但是如果它在WP平台上不可用,我将切换到UWP

解析StringValueAttribute以返回Enum

我目前有一个带有使用字符串值属性的枚举的Windows Phone 8.1运行时项目。 我希望能够通过使用字符串值属性来获取枚举值,例如使用“world”来获取summer的枚举值。 我正在使用Windows Phone 8.1运行时因此我发现的大多数方法都不起作用。 提前致谢。 public enum test { [StringValue(“hello”)] school, [StringValue(“world”)] summer, [StringValue(“fall”)] car } public class StringValueAttribute : Attribute { private string _value; public StringValueAttribute(string value) { _value = value; } public string Value { get { return _value; } } }