How to store user settings in windows rt app - windows-runtime

Coming from a mobile background (Android/iOS) both OS's have something that you can hold application preferences (SharedPreferences in android and NSUserDefaults in iOS) like boolean's, int's, strings's ect. which are just key/value pairs that the user can set for polling intervals or turning off something in the app.
What is the equivalent to that in Windows RT?

Windows.Storage.ApplicationData.Current.LocalSettings is a container where you can programmatically add/set key-value-pairs. Are you looking for that?
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localsettings.ASPx

Related

Change the system settings on the change of settings in the application

I have an UWP application which display the battery status. On change of power saving mode in the application need to reflect in System settings.
Is it possible in UWP?
Is it possible in UWP?
No, this is not possible in UWP. We can't change System Settings just within a UWP app programmatically. As #lindexi said, the proper way to achieve what you want is launching the Settings app and then let user change the battery saver setting.
To launch to the battery saver setting page, we can use "ms-settings:batterysaver" URI like the following:
bool result = await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:batterysaver"));
For more info, please see Launch the Windows Settings app.
And after this, we can use PowerManager.EnergySaverStatus property to check if user has enabled battery saver.

Store URL redirection not working on Windows 8.1

I'm trying to determine which Store URL I'm supposed to use. Now that Windows 10 is released I want to make sure that the Store URL is correct and that the redirection works as intended.
I followed Microsoft's own documentation (see here). Basically they say that I can use the following url-protocol/scheme to open the store for both Windows 10 and Windows 8: ms-windows-store://pdp/?PFN=Microsoft.Office.OneNote_8wekyb3d8bbwe. But this only seem to work on Windows 10, on Windows 8.1 it will open the store but not show the app. They recommend that one use this: ms-windows-store://pdp/?ProductId=9WZDNCRFHVJL but say that it is only recommended for Windows 10 users (also it doesn't work if tried on Windows 8.1).
I think I've tried all combinations on that page but it won't work for both OS:es. This can't possible be intended?

FileSavePicker and deprecated ApplicationViewState

In the documentation for the FileSavePicker, it states:
Warning If you try to show the file picker while your app is snapped the file picker will not be shown and an exception will be thrown. You can avoid this by making sure your app is not snapped or by unsnapping it before you call the file picker.
I'm currently checking to see if the app is snapped or not, and my app responds differently in each case. My default behavior isn't showing the FileSavePicker, either, so I can't just try and then fall back to something else. Nor do I want to force the app to unsnap.
However, ApplicationViewState is deprecated post-8.1. In that documentation and related searching, developers are advised to access the window size directly in order to determine proper behavior. However, if the view state is no longer available, how do I know if the file picker will throw an exception or not? At what size is the app considered 'snapped'?
Also, I'm using C++, so an answer compatible with C++ would be splendid. I wouldn't mind seeing the C# solution, too.
In regards to the FileSavePicker documentation - I believe that it is just an oversight. The text you quote was from the Windows 8 version, and to me it looks like it didn't get updated for Windows 8.1.
If you look at the FileOpenPicker documentation, you see that it was updated:
Important In Windows 8 if you attempt to display the file picker while your app is snapped, the file picker will not be shown and an exception will be thrown. You can avoid this by making sure your app is not snapped, or by unsnapping it before you call the file picker. ...Note that Windows 8.1 does not define a specific snapped window size. Instead, users can resize apps to any width, down to the minimum. Therefore, if your app will deploy only on Windows 8.1, you can ignore the EnsureUnsnapped function and calls to it in this topic's example code.
The last sentence (in bold) above essentially says that you can ignore state and safely open the file dialogs if you are running under Windows 8.1.
To test the above, I used VS 2012 to create a Windows 8 application with a file save picker (in C#). I believe the outcome will be the same with C++, but I am not 100% certain.
I should note that my test application does not check for view state and always tries to open a file dialog.
When the application is run under Windows 8 in the snapped state, the application causes an error. That same application (same binary) when run under Windows 8.1 allows the file save dialog to open without issue. As mentioned previously there is no snapped state in Windows 8.1, so the way I tested the application was to open the application to the minimum width (320 pixels).
To summarize:
If you are targeting Windows 8.0, you will have to make sure the application is unsnapped prior to opening the file picker dialogs.
If you are targeting Windows 8.1, you do not have to worry about state, as the file picker dialogs no longer throw any exceptions.

Saving images locally in windows phone 8.1 universal app

I want to download and save(cache) images locally in windows phone 8.1 universal app. so that if Phone is offline I can show users images(avatars) in ListView.
What is the best way of saving images to local storage(should I use local storage or I use sqlite as i am using sqlite to store user's other information)?
How can I save (download) images to local store?
Thanks!
There's a great extension by Q42 in their Q42.WinRT framework called ImageExtensions.cs
You use it on normal Image objects in XAML, but instead of setting the Source of the Image, you set the ImageExtensions.CacheUri.
<Image q42controls:ImageExtensions.CacheUri="https://www.google.com/favicon.ico" />
q42controls is just a namespace added on top of the XAML page
xmlns:q42controls="using:Q42.WinRT.Controls"
When the image is loaded, it's automatically cached!

Adobe Air - Open app in fullscreen

I created an Air desktop app with Flash CS 5. Usually Windows (XP) is opening an application (like Firefox) with the latest set size and position.
For my installed Air app it's always just the default one.
How to start it with the latest used size and position?
Thanks.
Uli
hope this will work for you:
http://cookbooks.adobe.com/post_Using_the_FullScreen_functionality_in_AIR-8004.html
http://blog.ochodurando.com/2010/04/adobe-air-e-fullscreen/
You need to save a record somewhere that remembers the window's size, and possibly position. If your app has a preferences file, this would be an ideal place to store that information. Then, whenever your app starts, it checks for this information and resizes the window if any values are found.
Most popular programs include this feature (and don't even mention it, since it's pretty basic UI), but it's done intentionally and not as a default for every application. Thus if you want it, you have to program it in.
You can read and write to application.xml. You'll find there and nodes.
file = new File( File.applicationDirectory.nativePath + "/META-INF/AIR/application.xml" );
Adobe restrict writing access to application diractory but this trick is useful if you don't want to create a separate config file in app-storage:/ folder, which is of course prefered.