procedure TDeviceInfoForm.btnGetDeviceInfoClick(Sender: TObject);
var
  Device : UIDevice;
begin
  Device := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
  lbOSName.Text := Format('OS Name: %s', [NSStrToStr(Device.systemName)]);
  lbOSVersion.Text := Format('OS Version: %s', [NSStrToStr(Device.systemVersion)]);
  lbDeviceType.Text := Format('Device Type: %s', [NSStrToStr(Device.model)]);
 
//code added for detecting battery level
  Device.setBatteryMonitoringEnabled(True);
  lblBatteryLevel.Text := Format ('Battery Level: %d', [Round(Device.batteryLevel*100)]);
end;

 https://community.embarcadero.com/blogs?view=entry&id=9356

posted on 2016-12-06 20:15  lypzxy  阅读(541)  评论(0编辑  收藏  举报