Einzelnen Beitrag anzeigen

philipp.hofmann

Registriert seit: 21. Mär 2012
Ort: Hannover
865 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: Android - Phone oder Tablet

  Alt 21. Feb 2023, 12:08
Delphi-Quellcode:
class function TMyDeviceInfo.isPhoneMode(form:TForm):boolean;
var FMyCustomMV : TMyDeviceInfo;
    ThisDevice: TDeviceInfo;
begin
  try
    FMyCustomMV := TMyDeviceInfo.Create(form);
    TPlatformServices.Current.SupportsPlatformService(IFMXDeviceService,FMyCustomMV.FDeviceService);
    ThisDevice := FMyCustomMV.GetDevice;
    case ThisDevice.DeviceClass of
      TDeviceInfo.TDeviceClass.Phone:
        begin
          Result:=true;
        end;
      TDeviceInfo.TDeviceClass.Tablet:
        begin
          Result:=false;
        end;
      TDeviceInfo.TDeviceClass.Desktop:
        begin
          Result:=false;
        end
      else begin
        Result:=true;
      end;
    end;
  except on E: Exception do
    begin
      Result:=false;
    end;
  end;
end;
  Mit Zitat antworten Zitat