Al T 12 Posted August 20, 2022 (edited) Here's the code that works in Delphi 11, but it wont work in XE8 because "[DCC Error] Unit1.pas(210): E2003 Undeclared identifier: 'TAndroidHelper' unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.Math, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdBaseComponent, IdThreadComponent, FMX.StdCtrls, FMX.Layouts, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, System.IOUtils, AndroidAPI.JNIBridge, Androidapi.JNI.JavaTypes, android.os.StatFs, Posix.Unistd, FMX.Memo.Types, Unit2, System.ImageList, FMX.ImgList, Androidapi.Log, Androidapi.JNI.App, Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers, credits, OptionsUnit; { MISC CODE IN BETWEEN } function AndroidGetMemory: Int64; var MemoryInfo: JActivityManager_MemoryInfo; AvailMb: Int64; begin MemoryInfo:= TJActivityManager_MemoryInfo.JavaClass.init; TJActivityManager.Wrap((TAndroidHelper.Context.getSystemService( TJContext.JavaClass.ACTIVITY_SERVICE) as ILocalObject).GetObjectID) .getMemoryInfo(MemoryInfo); AvailMb := MemoryInfo.availMem; result := AvailMb; end; I found the problem in the code above and changed it to this: uses Androidapi.Helpers, Androidapi.JNIBridge, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.App; function AndroidGetMemory: Int64; var MemoryInfo: JActivityManager_MemoryInfo; // TotalMb: Int64; AvailMb: Int64; begin MemoryInfo:= TJActivityManager_MemoryInfo.JavaClass.init; TJActivityManager.Wrap((SharedActivityContext.getSystemService( TJContext.JavaClass.ACTIVITY_SERVICE) as ILocalObject).GetObjectID) .getMemoryInfo(MemoryInfo); //TotalMb:= MemoryInfo.totalMem shr 20; //AvailMb:= MemoryInfo.availMem shr 20; in MB AvailMb:= MemoryInfo.availMem; result := AvailMb; end; SharedActivityContext was deprecated in Delphi 11 and uses TAndroidHelper.Context Edited August 20, 2022 by Al T Share this post Link to post