Skip to main content
Participant
January 3, 2011
Question

Launching pdf reader for document on SD card in android from actionscript

  • January 3, 2011
  • 2 replies
  • 2661 views

Is there a way to open pdf file from adobe air application on android (essentially invoking pdf reader)? On desktop, you would normally use File.openWithDefaultApplication(). This DOES NOT work on android.

This topic has been closed for replies.

2 replies

Participant
November 22, 2012

Use Document Launcher ANE, I have tried and it works pretty nice!

Romil Mittal
Adobe Employee
Adobe Employee
January 3, 2011

Yes, File.openWithDefaultApplication() is not supported for mobileDevice profile.

If a PDF reader has registered a custom URI scheme, you can open the PDF URL in browser from your AIR application, and that would in turn launch the PDF reader. Without a custom URI registered, the PDF file would just be downloaded by the browser and the user woudl have to manually click on the downloaded file to launch the PDF reader.

Thanks,

-romil

January 19, 2011

I have tried to use the URLRequest to make that work, but I'm having problems.

My Included files has a pdf called "test.pdf". I just want to see if I can open it up when I press the button.

(My code is below)

When it runs the dynamic text called 'test' displays "app:/test.pdf". think my URL is the issue. I'm having trouble pointing the browser to a local file. Ultimately I would like to point it to a directory on the SDCard, but this is my first test.

I REALLY wish we could open these in their native applications. If I can't get this to work then I guess I'm going to have to code my app in JAVA. Doh!

Thanks!

Mike

import flash.filesystem.*;


var dir = File.applicationDirectory;


loadBtn.addEventListener(MouseEvent.CLICK, loadPDF);


function loadPDF(e:MouseEvent):void{

 

  var myFile = dir.resolvePath("test.pdf");

  test.text = myFile.url;


  var req:URLRequest = new URLRequest("test.pdf");

navigateToURL(req);

}

Participating Frequently
April 28, 2011

You could always try just launching a webpage in the android device and showing the pdf in there.