unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Layouts, FMX.Memo;
type
TForm1 = class(TForm)
Button1: TButton;
mmo1: TMemo;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
uses Androidapi.JNI.android.os.PowerManager,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.JavaTypes,
Androidapi.Helpers,
Androidapi.JNIBridge;
{$R *.NmXhdpiPh.fmx ANDROID}
function GetPowerManager:JPowerManager ;
var
Native:JObject ;
begin
Native:=SharedActivityContext.getSystemService(TJContext.JavaClass.POWER_SERVICE);
if not Assigned(Native) then
begin
raise Exception.Create('Could not locate Connectivity Service');
end;
Result:=TJPowerManager.Wrap((Native as ILocalObject).GetObjectID) ;
if not Assigned(Result) then
begin
raise Exception.Create('Could not access Connectivity Manager');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
PowerManager:JPowerManager ;
begin
PowerManager:=GetPowerManager ;
if PowerManager.isScreenOn then
begin
ShowMessage('未关闭状态');
end
else
begin
ShowMessage('已经关闭状态');
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
PowerManager:JPowerManager ;
begin
PowerManager:=GetPowerManager ;
if PowerManager.isScreenOn then
begin
mmo1.Lines.Add('没有关闭')
end
else
begin
mmo1.Lines.Add('关闭状态') ;
end;
end;
end.
//====================================================
//
// 转换来自JavaClassToDelphiUnit
// 原始作者:ying32
// QQ: 1444386932
// 396506155
// Email:yuanfen3287@vip.qq.com
//
// 修改 By:Flying Wang & 爱吃猪头肉
// 请不要移除以上的任何信息。
// 请不要将本版本发到城通网盘,否则死全家。
//
// Email:1765535979@qq.com
//
// 生成时间:2014/12/19 星期五 10:29:24
// 工具版本:1.0.2014.12.12
//
//====================================================
unit Androidapi.JNI.android.os.PowerManager;
interface
uses
Androidapi.JNI.android.os.PowerManager_WakeLock,
Androidapi.JNIBridge,
Androidapi.JNI.JavaTypes,
Androidapi.JNI.os;
type
// ===== Forward declarations =====
JPowerManager = interface; //android.os.PowerManager
// ===== Interface declarations =====
JPowerManagerClass = interface(JObjectClass)
['{6600EE55-0B62-4AC6-8C41-9C0AD9AAE509}']
{ static Property Methods }
{class} function _GetPARTIAL_WAKE_LOCK: Integer;
{class} function _GetFULL_WAKE_LOCK: Integer;
{class} function _GetSCREEN_BRIGHT_WAKE_LOCK: Integer;
{class} function _GetSCREEN_DIM_WAKE_LOCK: Integer;
{class} function _GetACQUIRE_CAUSES_WAKEUP: Integer;
{class} function _GetON_AFTER_RELEASE: Integer;
{ static Methods }
{ static Property }
{class} property PARTIAL_WAKE_LOCK: Integer read _GetPARTIAL_WAKE_LOCK;
{class} property FULL_WAKE_LOCK: Integer read _GetFULL_WAKE_LOCK;
{class} property SCREEN_BRIGHT_WAKE_LOCK: Integer read _GetSCREEN_BRIGHT_WAKE_LOCK;
{class} property SCREEN_DIM_WAKE_LOCK: Integer read _GetSCREEN_DIM_WAKE_LOCK;
{class} property ACQUIRE_CAUSES_WAKEUP: Integer read _GetACQUIRE_CAUSES_WAKEUP;
{class} property ON_AFTER_RELEASE: Integer read _GetON_AFTER_RELEASE;
end;
[JavaSignature('android/os/PowerManager')]
JPowerManager = interface(JObject)
['{54AAD336-BDE4-447A-8A3C-235EEB4FF8EA}']
{ Property Methods }
{ methods }
function newWakeLock(flags: Integer; tag: JString): JPowerManager_WakeLock; cdecl;
procedure userActivity(when: Int64; noChangeLights: Boolean); cdecl;
procedure goToSleep(time: Int64); cdecl;
function isScreenOn: Boolean; cdecl;
procedure reboot(reason: JString); cdecl;
{ Property }
end;
TJPowerManager = class(TJavaGenericImport<JPowerManagerClass, JPowerManager>) end;
implementation
procedure RegisterTypes;
begin
TRegTypes.RegisterType('Androidapi.JNI.android.os.PowerManager.JPowerManager',
TypeInfo(Androidapi.JNI.android.os.PowerManager.JPowerManager));
end;
initialization
RegisterTypes;
end.
//====================================================
//
// 转换来自JavaClassToDelphiUnit
// 原始作者:ying32
// QQ: 1444386932
// 396506155
// Email:yuanfen3287@vip.qq.com
//
// 修改 By:Flying Wang & 爱吃猪头肉
// 请不要移除以上的任何信息。
// 请不要将本版本发到城通网盘,否则死全家。
//
// Email:1765535979@qq.com
//
// 生成时间:2014/12/19 星期五 10:29:44
// 工具版本:1.0.2014.12.12
//
//====================================================
unit Androidapi.JNI.android.os.PowerManager_WakeLock;
interface
uses
Androidapi.JNI.android.os.WorkSource,
Androidapi.JNIBridge,
Androidapi.JNI.JavaTypes,
Androidapi.JNI.os;
type
// ===== Forward declarations =====
JPowerManager_WakeLock = interface; //android.os.PowerManager$WakeLock
// ===== Interface declarations =====
JPowerManager_WakeLockClass = interface(JObjectClass)
['{5394217C-F576-4C1C-87B7-1EECC1893E74}']
{ static Property Methods }
{ static Methods }
{ static Property }
end;
[JavaSignature('android/os/PowerManager$WakeLock')]
JPowerManager_WakeLock = interface(JObject)
['{BD52A293-0D29-4637-B236-00D0DA2D50B1}']
{ Property Methods }
{ methods }
procedure setReferenceCounted(value: Boolean); cdecl;
procedure acquire; cdecl; overload;
procedure acquire(timeout: Int64); cdecl; overload;
procedure release; cdecl;
function isHeld: Boolean; cdecl;
procedure setWorkSource(ws: JWorkSource); cdecl;
function toString: JString; cdecl;
{ Property }
end;
TJPowerManager_WakeLock = class(TJavaGenericImport<JPowerManager_WakeLockClass, JPowerManager_WakeLock>) end;
implementation
procedure RegisterTypes;
begin
TRegTypes.RegisterType('Androidapi.JNI.android.os.PowerManager_WakeLock.JPowerManager_WakeLock',
TypeInfo(Androidapi.JNI.android.os.PowerManager_WakeLock.JPowerManager_WakeLock));
end;
initialization
RegisterTypes;
end.
//====================================================
//
// 转换来自JavaClassToDelphiUnit
// 原始作者:ying32
// QQ: 1444386932
// 396506155
// Email:yuanfen3287@vip.qq.com
//
// 修改 By:Flying Wang & 爱吃猪头肉
// 请不要移除以上的任何信息。
// 请不要将本版本发到城通网盘,否则死全家。
//
// Email:1765535979@qq.com
//
// 生成时间:2014/12/19 星期五 10:37:54
// 工具版本:1.0.2014.12.12
//
//====================================================
unit Androidapi.JNI.android.os.WorkSource;
interface
uses
Androidapi.JNIBridge,
Androidapi.JNI.JavaTypes,
Androidapi.JNI.os;
type
// ===== Forward declarations =====
JWorkSource = interface; //android.os.WorkSource
// ===== Interface declarations =====
JWorkSourceClass = interface(JObjectClass)
['{B839C6E0-F417-49DF-8DC9-51FD9BF7C217}']
{ static Property Methods }
{class} function _GetCREATOR: JParcelable_Creator;
{ static Methods }
{class} function init: JWorkSource; cdecl; overload;
{class} function init(orig: JWorkSource): JWorkSource; cdecl; overload;
{ static Property }
{class} property CREATOR: JParcelable_Creator read _GetCREATOR;
end;
[JavaSignature('android/os/WorkSource')]
JWorkSource = interface(JObject)
['{C0180882-E13D-4E8A-BDC9-108629C9F981}']
{ Property Methods }
{ methods }
procedure clear; cdecl;
function diff(other: JWorkSource): Boolean; cdecl;
procedure &set(other: JWorkSource); cdecl;
function add(other: JWorkSource): Boolean; cdecl;
function remove(other: JWorkSource): Boolean; cdecl;
function describeContents: Integer; cdecl;
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Property }
end;
TJWorkSource = class(TJavaGenericImport<JWorkSourceClass, JWorkSource>) end;
implementation
procedure RegisterTypes;
begin
TRegTypes.RegisterType('Androidapi.JNI.android.os.WorkSource.JWorkSource',
TypeInfo(Androidapi.JNI.android.os.WorkSource.JWorkSource));
end;
initialization
RegisterTypes;
end.