Download file from url and open in Android

Hello all:

It is possible with Delphi XE5 for android, download a file (pdf) from a url and open it in a android device?

How to do it?

Thanks in advance
0
Alfonso
10/17/2013 12:48:36 PM
embarcadero.delphi.firemonkey 4901 articles. 4 followers. Follow

5 Replies
3419 Views

Similar Articles

[PageSpeed] 6

> {quote:title=Alfonso Presa wrote:}{quote}
> Hello all:
> 
> It is possible with Delphi XE5 for android, download a file (pdf) from a url and open it in a android device?
> 
> How to do it?
> 
> Thanks in advance


// ** Open a URL

 

uses
  Androidapi.JNI.GraphicsContentViewText,
  FMX.Helpers.Android;


procedure TForm3.Button1Click(Sender: TObject);
var
  Intent: JIntent;
begin
  Intent := TJIntent.Create;
  Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
  Intent.setData(StrToJURI('http://www.google.com'));
  SharedActivity.startActivity(Intent);
end;


// ** Open a PDF File

uses
  Androidapi.JNI.GraphicsContentViewText,
  Androidapi.JNI.JavaTypes,
  FMX.Helpers.Android;


procedure TForm3.Button1Click(Sender: TObject);
var
  Intent: JIntent;
begin
  Intent := TJIntent.Create;
  Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
  Intent.setDataAndType(StrToJURI('filepath'),  StringToJString('application/pdf'));
  SharedActivity.startActivity(Intent);
end;
0
Sang
10/22/2013 3:25:54 AM
Thank's a lot!!!

But ,it's the same code to open url or  to download a file?




> {quote:title=Sang Hyun Oh wrote:}{quote}
> > {quote:title=Alfonso Presa wrote:}{quote}
> > Hello all:
> > 
> > It is possible with Delphi XE5 for android, download a file (pdf) from a url and open it in a android device?
> > 
> > How to do it?
> > 
> > Thanks in advance
> 
> 
> // ** Open a URL
> 
>  
> 
> uses
>   Androidapi.JNI.GraphicsContentViewText,
>   FMX.Helpers.Android;
> 
> 
> procedure TForm3.Button1Click(Sender: TObject);
> var
>   Intent: JIntent;
> begin
>   Intent := TJIntent.Create;
>   Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
>   Intent.setData(StrToJURI('http://www.google.com'));
>   SharedActivity.startActivity(Intent);
> end;
> 
> 
> // ** Open a PDF File
> 
> uses
>   Androidapi.JNI.GraphicsContentViewText,
>   Androidapi.JNI.JavaTypes,
>   FMX.Helpers.Android;
> 
> 
> procedure TForm3.Button1Click(Sender: TObject);
> var
>   Intent: JIntent;
> begin
>   Intent := TJIntent.Create;
>   Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
>   Intent.setDataAndType(StrToJURI('filepath'),  StringToJString('application/pdf'));
>   SharedActivity.startActivity(Intent);
> end;
0
Alfonso
10/22/2013 4:02:01 PM
Alfonso wrote:

> But ,it's the same code to open url or  to download a file?

You would try using a JIntent to open the URL to the PDF file, and see if 
the browser will open the file for you.  Otherwise, you can download the 
file yourself, such as with Indy's TIdHTTP component, and then use a JIntent 
to open it afterwards.

--
Remy Lebeau (TeamB)
0
Remy
10/22/2013 6:22:09 PM
I notice that in XE6 the StrToJURI seems to be missing or in a different Unit.  Anyone know if it just moved or if the code below is now invalid?

TIA,

P


> {quote:title=Sang Hyun Oh wrote:}{quote}
> > {quote:title=Alfonso Presa wrote:}{quote}
> > Hello all:
> > 
> > It is possible with Delphi XE5 for android, download a file (pdf) from a url and open it in a android device?
> > 
> > How to do it?
> > 
> > Thanks in advance
> 
> 
> // ** Open a URL
> 
>  
> 
> uses
>   Androidapi.JNI.GraphicsContentViewText,
>   FMX.Helpers.Android;
> 
> 
> procedure TForm3.Button1Click(Sender: TObject);
> var
>   Intent: JIntent;
> begin
>   Intent := TJIntent.Create;
>   Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
>   Intent.setData(StrToJURI('http://www.google.com'));
>   SharedActivity.startActivity(Intent);
> end;
>
0
Paul
6/3/2014 8:00:17 PM
Paul wrote:

> I notice that in XE6 the StrToJURI seems to be missing or in
> a different Unit.  Anyone know if it just moved or if the code
> below is now invalid?

It was moved to the Androidapi.Helpers unit.

--
Remy Lebeau (TeamB)
0
Remy
6/3/2014 8:10:49 PM
Reply:

Similar Artilces:

superreview granted: [Bug 363654] .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch : [Attachment 248458] disables .url in file:open
Stuart Morgan <stuart.morgan@alumni.case.edu> has granted Smokey Ardisson (unreliable; no bugmail) <alqahira@ardisson.org>'s request for superreview: Bug 363654: .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch https://bugzilla.mozilla.org/show_bug.cgi?id=363654 Attachment 248458: disables .url in file:open https://bugzilla.mozilla.org/attachment.cgi?id=248458&action=edit ------- Additional Comments from Stuart Morgan <stuart.morgan@alumni.case.edu> Well, that kinda sucks. ...

superreview requested: [Bug 363654] .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch : [Attachment 248458] disables .url in file:open
Smokey Ardisson (unreliable; no bugmail) <alqahira@ardisson.org> has asked Stuart Morgan <stuart.morgan@alumni.case.edu> for superreview: Bug 363654: .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch https://bugzilla.mozilla.org/show_bug.cgi?id=363654 Attachment 248458: disables .url in file:open https://bugzilla.mozilla.org/attachment.cgi?id=248458&action=edit ------- Additional Comments from Smokey Ardisson (unreliable; no bugmail) <alqahira@ardisson.org> Asking for sr on this 7-char patch in case we need to take it ...

superreview granted: [Bug 409538] Opening a . url file with auto-opening of downloads enabled can cause an infinite loop : [Attachment 294369] fix
Mark Mentovai <mark@moxienet.com> has granted Stuart Morgan <stuart.morgan@alumni.case.edu>'s request for superreview: Bug 409538: Opening a .url file with auto-opening of downloads enabled can cause an infinite loop https://bugzilla.mozilla.org/show_bug.cgi?id=3D409538 Attachment 294369: fix https://bugzilla.mozilla.org/attachment.cgi?id=3D294369&action=3Dedit ------- Additional Comments from Mark Mentovai <mark@moxienet.com> My only comments apply to existing stuff:=0D =0D >+// This takes an NSURL to a local file, and if that file is a file that= =...

superreview cancelled: [Bug 243324] Download manager fails to close with files that download very quickly (small files / cached files) : [Attachment 164976] check closeWhenDone pref before opening do
Son Le <lesx99@lycos.com> has cancelled Son Le <lesx99@lycos.com>'s request for superreview: Bug 243324: Download manager fails to close with files that download very quickly (small files / cached files) https://bugzilla.mozilla.org/show_bug.cgi?id=243324 Attachment 164976: check closeWhenDone pref before opening download window (v3) https://bugzilla.mozilla.org/attachment.cgi?id=164976&action=edit ...

superreview requested: [Bug 243324] Download manager fails to close with files that download very quickly (small files / cached files) : [Attachment 164976] check closeWhenDone pref before opening do
Son Le <lesx99@lycos.com> has asked Ben Goodger <bugs@bengoodger.com> for superreview: Bug 243324: Download manager fails to close with files that download very quickly (small files / cached files) https://bugzilla.mozilla.org/show_bug.cgi?id=243324 Attachment 164976: check closeWhenDone pref before opening download window (v3) https://bugzilla.mozilla.org/attachment.cgi?id=164976&action=edit ...

superreview requested: [Bug 243324] Download manager fails to close with files that download very quickly (small files / cached files) : [Attachment 164720] check closeWhenDone pref before opening do
Son Le <lesx99@lycos.com> has asked Ben Goodger <bugs@bengoodger.com> for superreview: Bug 243324: Download manager fails to close with files that download very quickly (small files / cached files) https://bugzilla.mozilla.org/show_bug.cgi?id=243324 Attachment 164720: check closeWhenDone pref before opening download window (v2) https://bugzilla.mozilla.org/attachment.cgi?id=164720&action=edit ...

superreview cancelled: [Bug 243324] Download manager fails to close with files that download very quickly (small files / cached files) : [Attachment 164720] check closeWhenDone pref before opening do
Son Le <lesx99@lycos.com> has cancelled Son Le <lesx99@lycos.com>'s request for superreview: Bug 243324: Download manager fails to close with files that download very quickly (small files / cached files) https://bugzilla.mozilla.org/show_bug.cgi?id=243324 Attachment 164720: check closeWhenDone pref before opening download window (v2) https://bugzilla.mozilla.org/attachment.cgi?id=164720&action=edit ...

superreview granted: [Bug 69114] Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) : [Attachment 143792] patch v4
Boris Zbarsky <bzbarsky@mit.edu> has granted Christian Biesinger <cbiesinger@gmx.at>'s request for superreview: Bug 69114: Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) http://bugzilla.mozilla.org/show_bug.cgi?id=69114 Attachment 143792: patch v4 http://bugzilla.mozilla.org/attachment.cgi?id=143792&action=edit ------- Additional Comments from Boris Zbarsky <bzbarsky@mit.edu> sr=bzbarsky, but I didn't verify general correctness of the win32 mumbo-jumbo (I don't know enough about win32 to do that). ...

superreview requested: [Bug 69114] Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) : [Attachment 143792] patch v4
Christian Biesinger <cbiesinger@gmx.at> has asked Brian Ryner (IBM) <bryner@brianryner.com> for superreview: Bug 69114: Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) http://bugzilla.mozilla.org/show_bug.cgi?id=69114 Attachment 143792: patch v4 http://bugzilla.mozilla.org/attachment.cgi?id=143792&action=edit ------- Additional Comments from Christian Biesinger <cbiesinger@gmx.at> I'll change nsIFileProtocolHandler's uuid before checking in ...

superreview requested: [Bug 69114] Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) : [Attachment 143792] patch v4 #2
Christian Biesinger <cbiesinger@gmx.at> has asked Boris Zbarsky <bzbarsky@mit.edu> for superreview: Bug 69114: Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) http://bugzilla.mozilla.org/show_bug.cgi?id=69114 Attachment 143792: patch v4 http://bugzilla.mozilla.org/attachment.cgi?id=143792&action=edit ...

superreview requested: [Bug 69114] Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) : [Attachment 143888] patch for callers, v2
Christian Biesinger <cbiesinger@gmx.at> has asked Brian Ryner (IBM) <bryner@brianryner.com> for superreview: Bug 69114: Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) http://bugzilla.mozilla.org/show_bug.cgi?id=69114 Attachment 143888: patch for callers, v2 http://bugzilla.mozilla.org/attachment.cgi?id=143888&action=edit ------- Additional Comments from Christian Biesinger <cbiesinger@gmx.at> I'll make those changes ...

superreview granted: [Bug 69114] Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) : [Attachment 143888] patch for callers, v2
Boris Zbarsky <bzbarsky@mit.edu> has granted Christian Biesinger <cbiesinger@gmx.at>'s request for superreview: Bug 69114: Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) http://bugzilla.mozilla.org/show_bug.cgi?id=69114 Attachment 143888: patch for callers, v2 http://bugzilla.mozilla.org/attachment.cgi?id=143888&action=edit ------- Additional Comments from Boris Zbarsky <bzbarsky@mit.edu> >Index: xpfe/components/bookmarks/src/nsBookmarksService.cpp The changes to this are fine. File a bug on firefox t...

superreview requested: [Bug 69114] Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) : [Attachment 143888] patch for callers, v2 #2
Christian Biesinger <cbiesinger@gmx.at> has asked Boris Zbarsky <bzbarsky@mit.edu> for superreview: Bug 69114: Opening Internet Shortcuts (.url files) doesn't work (using File | Open or file protocol) http://bugzilla.mozilla.org/show_bug.cgi?id=69114 Attachment 143888: patch for callers, v2 http://bugzilla.mozilla.org/attachment.cgi?id=143888&action=edit ...

Media URL/file handling question
Hello, I'm running Mozilla 1.6, as well as Firefox 0.8, on a MacOS X 10.3 system. The behavior I'm describing below is evident in both browsers. I've noticed that different media types are handled differently under my system depending on the player that the media is associated with. I have the three major media players under OS X (Quicktime, RealOne Player, and Windows Media Player 9) installed. If I click on a URL that points to a .mov or .mpg file, handled by Quicktime, the player is embedded in the browser window, and begins playing as soon as a sufficient b...

Web resources about - Download file from url and open in Android - embarcadero.delphi.firemonkey

Don't Download This Song - Wikipedia, the free encyclopedia
" Don't Download This Song " is the first single from "Weird Al" Yankovic 's 12th studio album Straight Outta Lynwood . The song was released ...

Facebook Adds To Download Your Information
Facebook increased the amount of information users can access when they download their account histories using the social network’s Download ...

Download the Facebook IQ digital magazine - Facebook for Business
The Facebook IQ digital magazine puts all the insights, best practices and key stats in one place. Download it on your mobile and read it anywhere. ...

Downloads
Download previous versions of the Facebook for iOS SDK.

‘Silent updates’ for Android download latest version of Facebook without Google Play
... users to receive app updates without going through the Google Play store. Some Android users are now receiving “silent updates,” which download ...

Lifehacker, tips and downloads for getting things done
Lifehacker curates tips, tricks, and technology for living better in the digital age.

Technology Product Reviews, News, Prices & Downloads - PCMag.com - PC Magazine
PC Magazine is your complete guide to PC computers, peripherals and upgrades. We test and review computer- and Internet-related products and ...

Indie Music News, MP3 Downloads, Music Videos, Reviews - Stereogum
MP3s downloads, music videos, concert reviews, tour dates and contests. Updated regularly.

RN Download ThisShow (@RNDownload) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here RN Download ThisShow @ RNDownload ...

Hey Siri, download Cortana to my iPhone later today, would you?
... , Cortana iPhone , Siri For more news on Apps , Siri , and Cortana continue reading at 9to5Mac . What do you think? Discuss "Hey Siri, download ...

Resources last updated: 12/14/2015 6:10:19 AM