Skip navigation
Currently Being Moderated

How to open a native PDF file in Android using AIR?

Jun 24, 2012 8:58 PM

Tags: #air #flex #android #mobile #stagewebview

Hello.I have created a flex mobile project to open and show a native PDF file in Android. I have tried three different methods below , but  I failed.

 

1. I created a stagewebview and used "stageWebView.loadURL". I can see the PDF View in emulator but it didn't work in Android Pad (SAMSUNG Galaxy Tab 10.1). It showed blank screen.

Note that I have installed AIR 3.3.

 

stageWebView1.loadURL(new File(new File("app:/assets/ZUGH-2P.pdf").nativePath).url);

 

2. I created a stagewebview and used stagewebview to load javascript. The javascript could run in emulator, but it didn't work in Android Pad. I failed again.

 

stageWebView1.loadURL(new File(new File("app:/assets/JavaScripthtml.html").nativePath).url);

 

3.  I imported stagewebviewbridge, which is the extended version of stagewebviewbridge. I created a stagewebviewbridge , but it could not run in emulator. I failed again.

 

 

stageWebViewbridge1.loadLocalURL( "appfile:/assets/pdf.html");
 

 

could any one give me some suggestions? Many thanks.

 
Replies
  • Currently Being Moderated
    Jun 25, 2012 6:43 AM   in reply to peterpan_cafuc

    I don't think Android supports that functionality.

    Try opening any PDF on the web with the browser on an Android device, it will download the PDF instead of displaying it.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 4:51 AM   in reply to PierreSolutions

    I think that @PierreSolutions is correct. Does your app exhibit that behavior (that is, does it download the PDF?) when running on the device?

     

    Regards,

    Randy Nielsen

    Senior Content and Community Manager

    Adobe Systems Incorporated

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 27, 2012 12:51 PM   in reply to peterpan_cafuc

    @peterpan_cafuc,

    Sorry to say that I'm not sure of the answer, either.

     

    One suggestion would be to try something like File.openWithDefaultApplication(), although I've never tried it on mobile.

     

    Also, I poked around stackoverflow, and it looks like people have done this using Android Intents, but you might have to use a Native Extension  to do this in AIR.

     

    Apologies that I can't be more helpful.

    -Randy

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 1:34 AM   in reply to peterpan_cafuc

    Has anybody found a solution to this problem? Thanks, Neil

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 6:53 AM   in reply to jazzwhistle

    I think the solution is an Android Native Extension to which you pass the path and file name. It would in turn call Android's file handling routines which would trigger the dialog asking which application should be used ... or if one was already associated with that file type, it would launch it.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 26, 2012 12:36 PM   in reply to PierreSolutions

    I found such an extension here http://activeden.net/item/document-launcher-native-extension-for-andro id/2015733 I have not tried it and can't vouch for it, but it seems to do what you are looking for.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2014 8:17 AM   in reply to PierreSolutions

    I know it has been a very long time, but air on android still does not allow PDFs opening on the device. I have used the above ane and just wanted to provide an update for anyone else seeking info..

    That ane does open PDF files as long as there is a reader available. It is also very easy to implement using two lines of code, or two lines and a basic function to tell the user that it needs a reader installed.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points