1
votes

I have downloaded the trial version of xe6 and playing with the sample called webbrowser.. I would like to close the app with the back button..

this is what i insert in the sample

procedure TWebBrowserForm.FormKeyUp(Sender: TObject; var Key: Word;
  var KeyChar: Char; Shift: TShiftState);
begin
  if Key = vkHardwareBack then
  begin
    SharedActivity.Finish;
  end;

This works and close the app..But when i click a link inside the browser and then press the back button the app wouldn't close ..

I also tried this http://www.fmxexpress.com/virtual-keyboard-with-twebbrowser-on-android-in-delphi-xe5-firemonkey/

2
It's normal behaviour. Your browser receives a focus and holds it (that's how Embarcadero has fixed a problem with writing text into edit fields on a html page). I am not sure, but try to move focus to another control on the form (may be you'll have to call TWebBrowser.SetFocus(False)), and then pressing Back again. - naXa
Also I suppose your problem is not replicable on Delphi XE5. - naXa
I have tried to focus on another control but no luck..the backbutton won't work..if you try the example from Embarcadero in xe5 or xe6 and handle the hardwareback key.. you will see the key won't fired when clicking a few links in the webbrowser.. - user3415232
I think EMB should fix this bug. - Leo
I think another bug is.When you type www.google.com and then search for example cars and try to click a link. you will get a white screen - user3415232

2 Answers

0
votes

Please Write onKeyDown event this

  if Key = vkHardwareBack then
  begin
    SharedActivity.Finish;
  end;
0
votes

On Android you can use a TMS Web browser instead. The component has an OnHardwareButtonClicked event which detects the Hardware Back button click. That's how I handled this problem. This component is very friendly when clicking on URLs inside a URL.