2012-10-11 67 views
1

我試圖刪除選項以啓用運行低內存設備(如諾基亞Lumia 610)的用戶在我的應用中啓用活動磁貼。我使用的是我從微軟獲得的代碼,但一些運行Lumia 800和Focus i917的用戶報告,在添加此功能後,實時磁貼功能消失。檢測低內存設備

檢測到低存儲設備的正確方法是什麼?

這是我使用的作品顯然在模擬器中對於一般的用戶,但不是所有的代碼:

long result = 0; 

try 
{ 
    result = (long)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit"); 
} 
catch (ArgumentOutOfRangeException) 
{ 
    //The device has not received the OS update, which means the device is a 512-MB device. 
} 

if (result < 90000000) 
{ 
    //Low memory device 
} 

回答

5

我用這個代碼。問題可能是在不斷,我的MSDN頁面是關於低內存設備:Developing for 256-MB Devices

/// <summary> 
/// Flag if device is Low-memory Tango device or not. 
/// </summary> 
public static bool IsLowMemDevice 
{ 
    get 
    { 
     if (!isLowMemDevice.HasValue) 
     { 
      try 
      { 
       // check the working set limit 
       long result = (long) DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit"); 
       isLowMemDevice = result < 94371840L; 
      } 
      catch (ArgumentOutOfRangeException) 
      { 
       // OS does not support this call => indicates a 512 MB device 
       isLowMemDevice = false; 
      } 
     } 
     return isLowMemDevice.Value; 
    } 
} 
private static bool? isLowMemDevice; 
+0

謝謝你的幫助。調試時,我永遠不會在isLowMemDevice中獲得值,並且代碼永遠不會執行。我應該在哪裏放置「private static bool?isLowMemDevice;」在我的頁面? – John

+0

我在AppHelper類中擁有它,然後可以隨意使用AppHelper.IsLowMemDevice屬性。 –