Delphi 使用NotificationCenter后显示键盘时Android应用程序冻结

Delphi 使用NotificationCenter后显示键盘时Android应用程序冻结,delphi,push-notification,keyboard,firemonkey,delphi-10.1-berlin,Delphi,Push Notification,Keyboard,Firemonkey,Delphi 10.1 Berlin,我在Delphi(柏林)上开发了一个巨大的应用程序,现在我遇到了一个无法解决的问题: 使用TNotificationCenter显示简单通知后,应用程序继续正常工作,一切正常,但当用户点击编辑时,应用程序在显示键盘后立即冻结,键盘仍在工作,但应用程序已冻结。或者,如果用户在任何编辑之前打开键盘,并且应用程序显示通知,则应用程序在显示通知之前冻结 我发现防止这种情况发生的唯一方法是评论这句话: NotificationCenter1.PresentNotification(MyNotifica

我在Delphi(柏林)上开发了一个巨大的应用程序,现在我遇到了一个无法解决的问题:

  • 使用TNotificationCenter显示简单通知后,应用程序继续正常工作,一切正常,但当用户点击编辑时,应用程序在显示键盘后立即冻结,键盘仍在工作,但应用程序已冻结。或者,如果用户在任何编辑之前打开键盘,并且应用程序显示通知,则应用程序在显示通知之前冻结
我发现防止这种情况发生的唯一方法是评论这句话:

NotificationCenter1.PresentNotification(MyNotification);
所以我的应用程序的唯一解决方案是删除所有通知或在其他开发平台上重新制作

有人得到提示吗

编辑:

因此,本机编辑并不能解决我的问题,实际上它会在通知显示事件后立即冻结应用程序,而无需点击编辑

然后,我从特定编辑中删除了所有main Form.OnShow事件、所有main Form.OnVirtualKeyBoardHidden和main Form.onvirtualkeyboardshow事件、所有main Form.KeyUp事件以及所有类型的事件,并进行了尝试。应用程序仍然冻结

显示通知的8秒计时器:

procedure TForm1.Timer3Timer(Sender: TObject);
var
  I,Brk:integer;
  RaioCemMetros:string;
  RaioMetrosF:double;
  Notif:boolean;
  aDay: TDateTime;
  aaStart,aaFinish: TTime;
  DayOk:boolean;
  HoraStart,MinStart,HoraFim,MinFim:string;
  Dia,Mes,Ano:string;
  Tipo: string;
  Dayofwk: integer;
  Navig:string;
begin
Label1.Text := '1 '+DownloadedAlerts.Text;
Brk := 0;
Notif := False;
if ((CityBackground.Tag = 0) and (IdDownloadClient.Tag = 0) and     (Form58.Image1.Tag = 0) and (Form64.Image1.Tag = 0) and (TabControl1.TabIndex =     0) and (DownloadedAlerts.Text <> '') and (LastNotifON = False) and (NotifOn))             then
  begin
Label1.Text := '2';
  LatS := StringReplace(lat,'.',',',[rfReplaceAll, rfIgnoreCase]);
  LongS := StringReplace(long,'.',',',[rfReplaceAll, rfIgnoreCase]);
  LatF := StrToFloat(LatS);
  LongF := StrToFloat(LongS);

  for I := 0 to DownloadedAlerts.Count-1 do
  begin
    Brk := I;
    EventLatURL := Copy(DownloadedAlerts[I],2,16);
    EventLongURL := Copy(DownloadedAlerts[I],19,16);
    EventLatS := StringReplace(EventLatURL,'.',',',[rfReplaceAll,     rfIgnoreCase]);
    EventLongS := StringReplace(EventLongURL,'.',',',[rfReplaceAll,     rfIgnoreCase]);
    EventLatF := StrToFloat(EventLatS);
    EventLongF := StrToFloat(EventLongS);
    DistanciaV := abs(LatF-EventLatF);
    DistanciaH := abs(LongF-EventLongF);

    distanciaGPS := sqrt(sqr(DistanciaV) + sqr(DistanciaH));
    distanciaMETROS := distanciaGPS*(111120*0.946);

    RaioCemMetros := Copy(DownloadedAlerts[I],55,4);
    RaioMetrosF := 100*StrToFloat(RaioCemMetros);

    if RaioMetrosF >= distanciaMETROS then
    begin
    Label1.Text := '3';
    DayOk := False;
    Dayofwk := DayOfTheWeek(Now);
      case Dayofwk of
        7: if (ansipos('11111111',DownloadedAlerts[I]) > 0) then DayOk := True;     // Domingo
        1: if (ansipos('22222222',DownloadedAlerts[I]) > 0) then DayOk := True;
        2: if (ansipos('33333333',DownloadedAlerts[I]) > 0) then DayOk := True;
        3: if (ansipos('44444444',DownloadedAlerts[I]) > 0) then DayOk := True;
        4: if (ansipos('55555555',DownloadedAlerts[I]) > 0) then DayOk := True;
        5: if (ansipos('66666666',DownloadedAlerts[I]) > 0) then DayOk := True;
        6: if (ansipos('77777777',DownloadedAlerts[I]) > 0) then DayOk := True;
      end;

      if (ansipos('99999999',DownloadedAlerts[I]) > 0) then DayOk := True;
      if ((DayOk = False) and (DownloadedAlerts[I].Contains('11111111') = False)     and (DownloadedAlerts[I].Contains('22222222') = False) and
       (DownloadedAlerts[I].Contains('33333333') = False) and     (DownloadedAlerts[I].Contains('44444444') = False) and
        (DownloadedAlerts[I].Contains('55555555') = False) and     (DownloadedAlerts[I].Contains('66666666') = False) and
         (DownloadedAlerts[I].Contains('77777777') = False)) then
      begin
         Dia := Copy(DownloadedAlerts[I],36,2);
         Mes := Copy(DownloadedAlerts[I],38,2);
         Ano := Copy(DownloadedAlerts[I],40,4);
         aDay := StrToDate(Dia+'/'+Mes+'/'+Ano);
         if aDay = Today then DayOk := True;
      end;
      if DayOk then
      begin
        HoraStart := Copy(DownloadedAlerts[I],45,2);
        MinStart := Copy(DownloadedAlerts[I],47,2);
        HoraFim := Copy(DownloadedAlerts[I],50,2);
        MinFim := Copy(DownloadedAlerts[I],52,2);

        aaStart:= StrToTime(HoraStart+':'+MinStart+':00');
        aaFinish := StrToTime(HoraFim+':'+MinFim+':59');

        if (TimeInRange(Now,aaStart,aaFinish)) = True then
        begin
        Label1.Text := '4';
          Tipo := Copy(DownloadedAlerts[I],1,1);
          Navig := Copy(DownloadedAlerts[I],35,1);
          Application.ProcessMessages;
          Notificationn := NotificationCenter1.CreateNotification;
          try
            if ((Tipo <> 'p') and (Tipo <> 'c')) then
            begin
              LastNotifOn := True;
              LastNotifLat := EventLatS;
              LastNotifLong := EventLongS;
              Label6.Text :=     Copy(DownloadedAlerts[I],60,ansipos('|',DownloadedAlerts[I])-60);
              if distanciaMETROS >= 1000 then Label7.Text :=     FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de distância agora' else
              Label7.Text := FloatToStr(RoundTo(distanciaMETROS,1))+' metros de     distância agora';
              Label9.Text := 'Alerta às '+IntToStr(HourOfTheDay(Now))+'h     '+IntToStr(MinuteOfTheHour(Now))+'m';
              Label10.Text :=     Copy(DownloadedAlerts[I],ansipos('|',DownloadedAlerts[I])+1,DownloadedAlerts[I].    Length-ansipos('|',DownloadedAlerts[I]));
              RoundRect1.Visible := True;
              RoundRect1.Opacity := 1.0;
              Rectangle5.Visible := True;
              Rectangle5.Opacity := 1.0;
            end;
            Notif := True;
            Image2.Visible := True;
            Label3.Visible := True;
            Button8.Visible := True;
            Notificationn.Name := 'Name';
            if Tipo = 'h' then begin
            Notificationn.Title := 'Alerta de Check-out';
            Notificationn.AlertBody := 'Hotel há menos de     '+FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de você';
            end else
            if ((Tipo = 'n') and (Parado)) then begin
            Notificationn.Title := 'Alerta de Área';
            Notificationn.AlertBody := 'Área com chamados reduzidos';  //     Primeira mensagem, que some em 1 segundo
            end else
            if Tipo = 'o' then begin
            Notificationn.Title := 'Alerta de Hospital';
            Notificationn.AlertBody := 'Hospital há menos de     '+FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de você';
            end else
            if Tipo = 'b' then begin
            Notificationn.Title := 'Alerta de Balada';
            Notificationn.AlertBody := 'Saída de balada há menos de     '+FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de você';
            end else
            if Tipo = 'f' then begin
            Notificationn.Title := 'Alerta de Partida';
            Notificationn.AlertBody := 'Saída de torcedores há menos de     '+FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de você';
            end else
            if Tipo = 'i' then begin
            Notificationn.Title := 'Alerta de Igreja';
            Notificationn.AlertBody := 'Missa próxima do fim há menos de     '+FloatToStr(RoundTo(distanciaMETROS,1))+' metros de você';
            end else
            if Tipo = 's' then begin
            Notificationn.Title := 'Alerta de Show';
            Notificationn.AlertBody := 'Show de música há menos de     '+FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de você';
            end else
            if Tipo = 'e' then begin
            Notificationn.Title := 'Alerta de Evento';
            Notificationn.AlertBody := 'Evento há menos de     '+FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de você';
            end else
            if Tipo = 'm' then begin
            Notificationn.Title := 'Motorista Ajudante';
            Notificationn.AlertBody := 'Mensagem do Motorista Ajudante';
            end else
            if Tipo = 'u' then begin
            Notificationn.Title := 'Alerta de Alunos';
            Notificationn.AlertBody := 'Saída de alunos há menos de     '+FloatToStr(RoundTo(distanciaMETROS/1000,-1))+' km de você';
            end else
            if Tipo = 'p' then begin
            Notificationn.Title := 'Posto em promoção';
            Notificationn.Name := 'Promocao';
            Notificationn.AlertBody := 'Combustível em promoção reportado por um     motorista há '+FloatToStr(RoundTo(distanciaMETROS,1))+' metros de você.';
            end else
            if Tipo = 'c' then begin
            Notificationn.Title := 'Chamado suspeito!';
            Notificationn.Name := 'Chamado';
            Notificationn.AlertBody := 'Solicitação suspeita foi reportada por     um motorista nesta região.';
            end;
            if Navig = '6' then begin
            Image2.Visible := False;
            Label3.Visible := False;
            Button8.Visible := False;
            end;
            Label1.Text := '5';
            Notificationn.EnableSound := False;
            Application.ProcessMessages;
            Label1.Text := '6';
            NotificationCenter1.PresentNotification(Notificationn);  // <<< Removing this line solves everything, but no Android notification is sent to the     user
            Label1.Text := '7';
            if NotifAudio = True then begin
              MediaPlayer1.FileName := (TPath.GetDocumentsPath + PathDelim +     'iclassy.mp3');
              MediaPlayer1.Play;
            end;
          finally
          Label1.Text := '8';
            Notificationn.DisposeOf;
            Label1.Text := '9';
          end;
        end;
      end;
    end;
  if Notif = True then Break;
  end;
   if Notif = True then
    begin
   Timer3.Tag := 0;
try
Label1.Text := '10';
   DownloadedAlerts.Delete(Brk);
   Label1.Text := '11';
except
Label1.Text := 'Except';
end;
    end else Timer3.Tag := 1;
   if ((Tipo = 'p') or (Tipo = 'c')) then
   begin
     LastNotifON := False;
     Timer3.Tag := 1;
   end;
  end;
end;
程序TForm1.Timer3Timer(发送方:TObject);
变量
一、 Brk:整数;
RaioCemMetros:字符串;
raiosf:double;
Notif:布尔型;
每日:TDateTime;
aaStart,aaFinish:TTime;
DayOk:布尔型;
HoraStart、MinStart、HoraFim、MinFim:string;
直径、Mes、Ano:字符串;
提波:弦;
Dayofwk:整数;
导航:字符串;
开始
标签1.Text:=“1”+下载的Alerts.Text;
Brk:=0;
Notif:=假;
如果((CityBackground.Tag=0)和(IdDownloadClient.Tag=0)和(Form58.Image1.Tag=0)和(Form64.Image1.Tag=0)和(TabControl1.TabIndex=0)和(downloadeAlerts.Text'')和(LastNotifON=False)和(NotifOn)),则
开始
标签1.文本:='2';
LatS:=StringReplace(lat,,,,,,[rfReplaceAll,rfIgnoreCase]);
LongS:=StringReplace(long,,,,,[rfReplaceAll,rfIgnoreCase]);
LatF:=StrToFloat(LatS);
LongF:=StrToFloat(LongS);
对于I:=0下载的Alerts.Count-1 do
开始
Brk:=I;
EventLatURL:=副本(下载的文件[I],2,16);
EventLongURL:=副本(下载的文件[I],19,16);
EventLatS:=StringReplace(EventLatURL,,,,,[rfReplaceAll,rfIgnoreCase]);
EventLongS:=StringReplace(EventLongURL,,,,,[rfReplaceAll,rfIgnoreCase]);
EventLatF:=StrToFloat(EventLatS);
EventLongF:=StrToFloat(EventLongS);
距离:=abs(LatF EventLatF);
距离:=abs(LongF EventLongF);
距离:等于sqrt(sqr(distanceav)+sqr(distanceah));
distanceametros:=distanceagps*(111120*0.946);
RaioCemMetros:=副本(下载文件[I],55,4);
RaioMetrosF:=100*StrToFloat(RAIOCMETROS);
如果RaioMetrosF>=距离,则
开始
标签1.文本:='3';
DayOk:=假;
DayOfk:=星期一(现在);
Dayofwk案
7:如果(ansipos('11111111',下载的文件[I])>0,那么DayOk:=True;//多明戈
1:如果(ansipos('22222',downloadeAlerts[I])>0,那么DayOk:=True;
2:如果(ansipos('33333333',DownloadedAlerts[I])>0,则DayOk:=True;
3:如果(ansipos('4444',DownloadedAlerts[I])>0,则DayOk:=True;
4:如果(ansipos('555555',downloadeAlerts[I])>0,那么DayOk:=True;
5:如果(ansipos('666666',DownloadedAlerts[I])>0,则DayOk:=True;
6:如果(ansipos('777777',DownloadedAlerts[I])>0,则DayOk:=True;
结束;
如果(ansipos('9999999',DownloadedAlerts[I])>0,则DayOk:=True;
如果((DayOk=False)和(downloadeAlerts[I].Contains('11111111')=False)和(downloadeAlerts[I].Contains('22222')=False)和
(DownloadedAlerts[I]。包含('33333333')=False)和(DownloadedAlerts[I]。包含('444444')=False)和
(DownloadedAlerts[I]。包含('555555')=False)和(DownloadedAlerts[I]。包含('66666666')=False)和
(下载的文件[I].Contains('7777')=False))然后
开始
直径:=副本(下载文件[I],36,2);
Mes:=副本(下载文件[I],38,2);
Ano:=副本(下载文件[I],40,4);
每日:=标准日期(直径+'/'+Mes+'/'+Ano);
如果aDay=今天,则DayOk:=真;
结束;
如果可以的话
开始
HoraStart:=副本(下载文件[I],45,2);
MinStart:=副本(下载文件[I],47,2);
HoraFim:=副本(下载文件[I],50,2);
MinFim:=副本(下载文件[I],52,2);
aaStart:=strottime(HoraStart+':'+MinStart+':00');
aaFinish:=strotime(HoraFim+':'+MinFim+':59');
如果(TimeInRange(Now,aaStart,aaFinish))=True,则
开始
标签1.文本:='4';
Tipo:=副本(下载文件[I],1,1);
Navig:=副本(下载文件[I],35,1);
Application.ProcessMessages;
Notificationn:=NotificationCenter1.CreateNotification;
尝试
如果((Tipo'p')和(Tipo'c')),则
开始
LastNotifOn:=真;
LastNotifLat:=事件数;
LastNotifLong:=事件长度;
标签6.Text:=副本(下载文件[I],60,ansipos(“|”,下载文件[I])-60);
如果distanceametros>=1000,则Label7.Text:=FloatToStr(RoundTo(distanceametros/1000,-1))+“km de distance–ncia agora”else
Label7.Text:=FloatToStr(RoundTo(distanceametros,1))+“metros de dist–ncia agora”;
Label9.Text:='Alertaás'+IntToStr(小时(现在))+'h'+IntToStr(小时(现在))+'m';
Label10.Text:=复制(下载文件[I],ansipos('|',下载文件[I])+1,下载文件[I]。长度ansipos('|',下载文件[I]);
RoundRect1.可见:=真;
RoundRect1.不透明度:=1.0;
矩形5.可见:=真;
矩形5.不透明度:=1