AndroidDeviceManager.java 940 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. package com.amazon.lumberyard;
  9. import android.app.ActivityManager;
  10. import android.content.Context;
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. public class AndroidDeviceManager
  13. {
  14. public static Context context;
  15. public static final float bytesInGB = (1024.0f * 1024.0f * 1024.0f);
  16. public static float GetDeviceRamInGB()
  17. {
  18. ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
  19. ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
  20. actManager.getMemoryInfo(memInfo);
  21. float totalMemory = memInfo.totalMem / bytesInGB;
  22. return totalMemory;
  23. }
  24. }