首页 > 代码库 > 获取电池用电情况

获取电池用电情况

以下摘自:http://blong.com/Articles/DelphiXE6AndroidActivityResult/ActivityResult.htm

unit ShowBatteryUsageActivity;

interface

procedure ShowBatteryUsage;

implementation

uses
  FMX.Helpers.Android, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Toast;

procedure ShowBatteryUsage;
var
  Intent: JIntent;
  ResolveInfo: JResolveInfo;
begin
  Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_POWER_USAGE_SUMMARY);
  ResolveInfo := SharedActivity.getPackageManager.resolveActivity(Intent, 0);
  if ResolveInfo = nil then
    Toast(‘Cannot display battery usage‘, ShortToast)
  else
    SharedActivity.startActivity(Intent);
end;

end

获取电池用电情况