{"id":1935,"date":"2015-02-03T04:07:58","date_gmt":"2015-02-02T20:07:58","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=1935"},"modified":"2015-02-03T04:07:58","modified_gmt":"2015-02-02T20:07:58","slug":"fmx-%e6%b3%a8%e5%86%8c%e4%b8%80%e4%b8%aa%e7%94%b1-android-%e8%b0%83%e7%94%a8%e7%9a%84intent","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=1935","title":{"rendered":"[FMX] \u6ce8\u518c\u4e00\u4e2a\u7531 Android \u8c03\u7528\u7684Intent"},"content":{"rendered":"<p>\u8fd9\u6bb5\u4ee3\u7801\u662f\u4ece FMX.Notification.Android \u4e2d\u62bd\u51fa\u6765\u7684\uff0c\u4ece\u4e2d\u6211\u4eec\u53ef\u4ee5\u5b66\u4e60\u5982\u4f55\u6ce8\u518c\u4e00\u4e2a Intent \u5206\u4eab\u6570\u636e\u3002FMX \u76ee\u524d\u6211\u4e5f\u662f\u5728\u5b66\u4e60\uff0c\u6240\u4ee5\u6709\u4e9b\u4e1c\u897f\u6211\u4e5f\u4e0d\u597d\u4e71\u89e3\u91ca\uff0c\u6bd5\u7adf\u4ffa\u4e0d\u662f\u5f88\u719f\uff0c\u8bef\u4eba\u5b50\u5f1f\u8fd8\u662f\u4e0d\u8981\u4e86\u3002\u5927\u5bb6\u81ea\u5df1\u770b\u6e90\u7801\u5206\u6790\u597d\u4e86\u3002<\/p>\n<pre class=\"lang:delphi decode:true\">procedure TNotificationCenterAndroid.ScheduleNotification(const ANotification: TNotification);\r\n\r\n  function CreateNotificationAlarmIntent(const AID: Integer): JPendingIntent;\r\n  var\r\n    Intent: JIntent;\r\n    Alarm: JFMXNotificationAlarm;\r\n  begin\r\n    Alarm := TJFMXNotificationAlarm.Create;\r\n    Intent := TJIntent.Create;\r\n    Intent.setClass(SharedActivityContext, Alarm.getClass);\r\n    Intent.setAction(TJFMXNotificationAlarm.JavaClass.ACTION_FMX_NOTIFICATION);\r\n    SaveNotificationIntoIntent(Intent, ANotification, AID);\r\n    Result := TJPendingIntent.JavaClass.getBroadcast(SharedActivityContext, AID, Intent,\r\n      TJPendingIntent.JavaClass.FLAG_UPDATE_CURRENT);\r\n  end;\r\n\r\nvar\r\n  PendingIntent: JPendingIntent;\r\n  ID: Integer;\r\nbegin\r\n  if not ANotification.Name.IsEmpty and FExternalStore.Contains(ANotification.Name) then\r\n    CancelNotification(ANotification.Name);\r\n\r\n  ID := TGeneratorUniqueID.GenerateID;\r\n  PendingIntent := CreateNotificationAlarmIntent(ID);\r\n  FExternalStore.SaveNotification(ANotification, ID);\r\n  SharedAlarmManager.&amp;set(TJAlarmManager.JavaClass.RTC_WAKEUP,\r\n    DateTimeLocalToUnixMSecGMT(ANotification.FireDate), PendingIntent);\r\nend;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u6bb5\u4ee3\u7801\u662f\u4ece FMX.Notificat [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[145,69,8,21],"tags":[317],"class_list":["post-1935","post","type-post","status-publish","format-standard","hentry","category-android","category-c-builder","category-delphi","category-misc","tag-317"],"views":3629,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1935"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1935\/revisions"}],"predecessor-version":[{"id":1936,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1935\/revisions\/1936"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}