Recently, we have seen news about the upcoming release of Nokia Lumia 520 and 720 on the Internet. I believe these two mobile phones will quickly enter the market at a more affordable price, as a result, developers will be concerned about the hardware difference. What changes should we pay attention to or make during the development process? Today, I want to talk about some important points on devices with limited hardware functionality.
First, let's talk about the memory.
The two names "low-memory devices" and "high-memory devices" are clearly defined. The msdn explanation is that mobile phones with over 1 GB of memory are referred to as high-memory devices. That is to say, 1 GB is the watershed of these two devices.
We can see that in our general applications, the memory limit for low memory devices is 180 MB, and that for high memory devices is 380 MB.
Of course, if you want to run some functions of your application only on high-memory devices, you can get the best running effect throughCodeYes, you can determine the implementation:
Private Void Application_launching ( Object Sender, launchingeventargs e ){ Try { // Check the working set limit and set the islowmemdevice flag accordingly. Int64 result = (int64) deviceextendedproperties. getvalue ( " Applicationworkingsetlimit " ); If (Result < 94371840l ) Mainpage. islowmemdevice = True ; Else Mainpage. islowmemdevice =False ;} Catch (Argumentoutofrangeexception ){ // Windows Phone OS update not installed, which indicates a 512-mb device. Mainpage. islowmemdevice = False ;}}
Of course94371840lIt is a threshold value that can be set by yourself.
Reference: http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/hh855083 (V = vs.105). aspx
In addition, I can also apply for more memory usage space on a low-memory device (if needed)
< App > ... < Requirements > < Requirement Name = "Id_req_frontcamera" /> </ Requirements > < Functionalcapabilities > < Functionalcapability Name = "Id_funccap_extend_mem" /> </ Functionalcapabilities > </ App >
The code above demonstrates how to useId_funccap_extend_mem is not forcibly exited when the application memory usage exceeds Mb on a low-memory device.
< App > ... < Requirements > < Requirement Name = "Id_req_frontcamera" /> < Requirement Name = "Id_req_memory_300" /> </ Requirements > </ App >
And declaredId_req_memory_300 indicates that the application will not be searched by low-memory devices and cannot be installed.
If you want to reduce memory usage in your application, consider the following:
- Webbrowser, map, and camera all have extra memory overhead. Use Windows Phone starters/selectors whenever possible.
- Avoid using a long data list. If you use it, ensure that it is paginated. Load data as needed instead of loading all data at once.
- Avoid using complex item templates with images. If yes, monitor the memory usage of the application.
- Avoid using complex animations for page transitions. This includes the transition in the Windows Phone toolkit. If transition is used, ensure that the application remains responsive and test the memory usage of the application during the page transition.
- Note: If you change the device direction when running an application, the memory used by the application may increase. The application should be tested when the direction is changed, and if the application usually exceeds the memory limit of 90-MB (180 MB), the low memory device should be removed.
Hardware requirements:
To modify the configuration file, you can use the configuration designer. However, in some cases, you must manually edit the XML content of the file. For example, if any of the following conditions is true, you must manually edit the XML:
- Declare that the application uses extended Association attributes.
- Declare that the application uses the location service and runs in the background.
- Declare that the application cannot run on devices with limited memory.
The configuration designer has four pages:
- ApplicationProgramUI
- Function
- Requirements
- Package
There is nothing special about the application UI.
Function page:Here we declare that your application will involve the use of those APIs, which can be used in the application only after the declaration. Otherwise, this function will be disabled on the device.
For a list of hardware requirements and determining functions, see:
Hardware requirements http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206936 (V = vs.105). aspx
Feature list http://msdn.microsoft.com/en-us/library/windowsphone/develop/gg180730 (V = vs.105). aspx
The options are displayed in the App Store prompts. For example, this app will get your location information, your address book information, and change your screen lock image...
Requirements page
By selecting the above hardware information, you can prevent your application from being installed on devices that do not support secondary hardware requirements:
Of course, we can also disable and determine whether these functions are supported in the Code. Here I suggest you configure hardware unsupported conditions by using the code as much as possible, if there is no way to download and discard some devices.
For example, the code used to determine whether a device supports a flashlight and control whether to enable or disable the flashlight is as follows:
// Activate a flash mode. // Cycle through flash mode options when the flash button is pressed. Private Void Changeflash_clicked (Object Sender, routedeventargs e ){ Switch (Cam. flashmode ){ Case Flashmode. off: If (Cam. isflashmodesupported (flashmode. On )){ // Specify that flash shoshould be used. Cam. flashmode = Flashmode. On; flashbutton. Content = " FL: On " ; Currentflashmode = " Flash mode: On " ;} Break ; Case Flashmode. on: If (Cam. isflashmodesupported (flashmode. redeyereduction )){ // Specify that the red-eye direction ction flash shoshould be used. Cam. flashmode = Flashmode. redeyereduction; flashbutton. Content = " FL: RER " ; Currentflashmode = " Flash mode: redeyereduction " ;} Else If (Cam. isflashmodesupported (flashmode. Auto )){ // If red-eye direction ction is not supported, specify automatic mode. Cam. flashmode = Flashmode. Auto; flashbutton. Content = " FL: Auto " ; Currentflashmode = " Flash mode: Auto " ;} Else { // If Automatic is not supported, specify that no flash shocould be used. Cam. flashmode = Flashmode. off; flashbutton. Content = " FL: Off " ; Currentflashmode = " Flash mode: Off " ;} Break ; Case Flashmode. redeyereduction: If (Cam. isflashmodesupported (flashmode. Auto )){ // Specify that the flash shocould be used in the automatic mode. Cam. flashmode = Flashmode. Auto; flashbutton. Content = " FL: Auto " ; Currentflashmode = " Flash mode: Auto " ;} Else { // If Automatic is not supported, specify that no flash shocould be used. Cam. flashmode = Flashmode. off; flashbutton. Content = " FL: Off " ; Currentflashmode = " Flash mode: Off " ;} Break ; Case Flashmode. Auto: If (Cam. isflashmodesupported (flashmode. Off )){ // Specify that no flash shocould be used. Cam. flashmode = Flashmode. off; flashbutton. Content = " FL: Off " ; Currentflashmode = " Flash mode: Off " ;} Break ;} // Display current flash mode. This . Dispatcher. begininvoke ( Delegate () {Txtdebug. Text = Currentflashmode ;});}
For more code examples and explanations, see: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206936 (V = vs.105). aspx # bkmk_hardwarerequirements
Packaging page
You can also specify the default language and other languages supported by the page. The value you provide for the default language and supported language determines the language support of your application seen in the store. You can manually edit these two values. However, they are closely related to the non-specific words in the project attributes and the supported regional settings. For all devices.
You are welcome to communicate with me here or on Sina Weibo.@ Wang Bo _ Nick