Delphi android 使用 TNotificationCenter 组件来显示系统通知  
官方Delphi 学习QQ群: 682628230(三千人)\n
频道

Delphi android 使用 TNotificationCenter 组件来显示系统通知


unit MainForm;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation,
  FMX.StdCtrls, System.Notification;

type
  TForm1 = class(TForm)
    ButtonShowNotification: TButton;
    NotificationCenter1: TNotificationCenter;
    procedure ButtonShowNotificationClick(Sender: TObject);
  private
    { Private declarations }
    procedure ShowNotification(const ATitle, AMessage: string);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.ButtonShowNotificationClick(Sender: TObject);
begin
  ShowNotification('通知标题', '这是一个系统通知示例');
end;

procedure TForm1.ShowNotification(const ATitle, AMessage: string);
var
  Notification: TNotification;
begin
  Notification := NotificationCenter1.CreateNotification;
  try
    Notification.Name := 'MyNotification';
    Notification.Title := ATitle;
    Notification.AlertBody := AMessage;
    NotificationCenter1.PresentNotification(Notification);
  finally
    Notification.Free;
  end;
end;

end.



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.10496807098389 seconds