Tuesday, October 4, 2011

Opening a URL from an iOS FireMonkey application

Q: How do you open a URL in Safari on the iPhone using FireMonkey?
A: You use UIApplication.sharedApplication.openUrl

Below is a very simple unit that will do the code. Just create an iOS app with one button and add the following code to the unit.

unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
// Open a URL
{$IFDEF FPC}
UIApplication.sharedApplication.openUrl(NSUrl.URLWithString(NSSTR(PChar('http://blogs.embarcadero.com/ao'))));
{$ENDIF}
end;

end.

9 comments:

  1. Good morning my friend.
    I need open a url in main form using firemonkey, but I don't know this.
    You can explain a few about this?

    Best regards from a brazilian student.

    ReplyDelete
  2. I've been surfing online greater than 3 hours as of late, yet I by no means discovered any attention-grabbing article like yours. It is pretty worth enough for me. Personally, if all website owners and bloggers made good content as you probably did, the net shall be a lot more helpful than ever before.

    ReplyDelete
  3. gallery furniture...

    The Hacker’s Corner » Blog Archive » Opening a URL from an iOS FireMonkey application...

    ReplyDelete
  4. Hi, i believe that i saw you visited my web site so i got here to return the prefer?.I'm attempting to find things to improve my site!I suppose its adequate to use a few of your ideas!!

    ReplyDelete
  5. Hey There. I discovered your weblog the use of msn. This is a really smartly written article. I'll be sure to bookmark it and return to learn more of your helpful information. Thank you for the post. I will definitely comeback.

    ReplyDelete
  6. Great goods from you, man. I have be aware your stuff previous to and you are just extremely great. I really like what you have received right here, really like what you are stating and the best way wherein you are saying it. You make it entertaining and you still care for to keep it sensible. I can't wait to read much more from you. That is really a great web site.

    ReplyDelete
  7. Thank you lots pertaining to expressing that effortlessly persons you acknowledge what you are speaking about! Saved as a favorite. Please also talk to my website Equates to).. online training You can have a backlink buy and sell deal amongst us

    ReplyDelete
  8. Hi there very cool web page! Guy. Beautiful. Awesome. I am going to save your website as well as go ahead and take rss feeds in addition? I am contented to search out numerous techniques the following from the submit, we start to use create more practices labels on homeopathic products, appreciation for giving.

    ReplyDelete
  9. It is nice look. Furniture is mostly used to make a student chairs in classrooms & drawing table. kindergarten, Library, Auditorium are the places were educational furniture used, and our all institution furniture is more attractive.

    ReplyDelete

Note: Only a member of this blog may post a comment.