Hi! someone tested new xe7 savestate feature on adroid platform ?

Hi! someone tested new xe7 savestate feature on adroid platform ? 

i tried to use it to make a simple "store/read  ini"  for some tedit text, but in android system onSaveState is never called....

my simple code:

procedure TFImpostazioni.FormCreate(Sender: TObject);
var
  R: TBinaryReader;
begin
  inherited ;
  SaveState.StoragePath := TPath.GetSharedDocumentsPath() ;
  if SaveState.Stream.Size > 0 then begin
        R := TBinaryReader.Create(SaveState.Stream);
        try
        edAppID.Text := R.ReadString ;
        edRestKey.Text := R.ReadString ;
        edMasterKey.Text := R.ReadString ;
        edUtente.Text := R.ReadString ;
        edPassword.Text := R.ReadString ;
        finally
          r.Free ;
        end;
  end;
end;

procedure TFImpostazioni.FormSaveState(Sender: TObject);
var
  W: TBinaryWriter;
begin
  inherited ;
  SaveState.Stream.Clear;
  W := TBinaryWriter.Create(SaveState.Stream);
  try
  w.Write(edAppID.Text );
  w.Write(edRestKey.Text );
  w.Write(edMasterKey.Text );
  w.Write(edUtente.Text );
  w.Write(edPassword.Text );
  finally
    w.Free ;
  end;
end;

Comments

  1. I have no such problem in android 4.0+.

    ReplyDelete
  2. why do you change the StorePath property ?
    Anyway, I don't know how Delphi handle this event, but on Android the SaveState occurs only when the application is closed by the OS (background application closed because of out of resources....) not when the user leaves the application.

    ReplyDelete
  3. As embarcadero wiki says, You must change storagepath if you want to make saving permanently. Maybe you are right, in android is not possible use this way to act as 'ini' file :)

    ReplyDelete
  4. Moreoever, that will trigger when home button been clicked.  But won't trigger when back button been clicked.

    ReplyDelete
  5. I tried with debugger options 'don't keep activities in background' but nope, event never called :(
    Now i resolved in old style way: write ini file :)

    ReplyDelete
  6. if you change StoredPath in OnCreate you should change it also in OnSaveState anyway

    ReplyDelete

Post a Comment