Last active
August 29, 2015 14:04
-
-
Save freeonterminate/809a1cabe610e2768fa7 to your computer and use it in GitHub Desktop.
バックグラウンドプロセス化したアプリが Front に戻ってきたとき真っ黒問題に対処するコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// あんまり、おこらないかもしれない! | |
// | |
// IFMXApplicationEventService をTPlatformServices.Current.GetPlatformService から取り出して | |
// AppEventService.SetApplicationEventHandler(AppEvent); をして | |
// そのイベントハンドラで以下の様にする | |
function TLifecycleManager.AppEvent( | |
iAppEvent: TApplicationEvent; | |
iContext: TObject): Boolean; | |
begin | |
Result := False; | |
case iAppEvent of | |
TApplicationEvent.WillBecomeForeground: begin | |
{$IFDEF ANDROID} | |
// onWindowFocusChanged を呼ぶと TWindowManager.Render が呼ばれて再描画される | |
TThread.Queue( | |
TThread.Current, | |
procedure | |
begin | |
PANativeActivity(System.DelphiActivity)^. | |
callbacks^. | |
onWindowFocusChanged(System.DelphiActivity, 1); | |
end | |
); | |
{$ENDIF} | |
CallEvent(FOnWillBecomeForeground); | |
end; | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment