5 Replies Latest reply on Aug 16, 2011 8:52 AM by dinesena

    openeing a pdf with native pdf reader: openwithdefaultapplication

    dinesena

      Hello,

      Wondering if anyone can help on this one. From what I have read AIR for android does not support openwithdefaultapplication. The device I am developing for , the Motorola Xoom does not support pdf viewing in StageWebView or the browser. I have tried stagewebview and navigatetourl witn no success. So is it possible to open my pdf's with the native pdf viewer, calling it from my flex mobile app, developed in FB4.5 Any tips/ links sample code on how to do this, if it is possible would be great.

       

      Thanks

        • 1. Re: openeing a pdf with native pdf reader: openwithdefaultapplication
          Joe ... Ward Level 4

          This doesn't appear to be possible. Even the Android browser doesn't open the default PDF viewer. Clicking a link to the PDF will download it, but not open it.

          • 2. Re: openeing a pdf with native pdf reader: openwithdefaultapplication
            johnteal

            It's rather a sad statement that Adobe can't figure out a way to allow its own products, like AIR and Flash, to open its own (supposedly universal) PDF documents when other competing platforms, like iOS, can. Come on Adobe, I'm trying to be suportive and not go over to the Dark (Apple) Side. Don't make me look like an idiot.

            .

            • 3. Re: openeing a pdf with native pdf reader: openwithdefaultapplication
              Rangora Level 3

              You can use : Extending AIR for Android

               

              I did it in my own application and it works. You start a socket in a native service and you connect to that socket from AIR. You will send a code (1 for example) to tell the socket you want him to open a PDF and you will send the PDF URL. The socket will create an intent of type "application/pdf". With AIR 3, you should be able to do it with native code in your AIR app... Since you want to send the intent from a service, you will have to add parameters... It will look like this :

               

              File file = new File(url);
              if (file.exists())
              { 
                   Intent intent = new Intent();
                   intent.setAction(android.content.Intent.ACTION_VIEW);
                   intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                   intent.setDataAndType(Uri.fromFile(file), "application/pdf");
                   try
                   {
                        getApplicationContext().startActivity(intent); 
                   }
                   catch (ActivityNotFoundException e) 
                   {
                        //Decide what to do if there is no application that handle the PDF MIME.
                   }
              }
              
              • 4. Re: openeing a pdf with native pdf reader: openwithdefaultapplication
                Marvin Blase

                ... didn't read the motorala issue.

                 

                Message was edited by: Marvin Blase

                • 5. Re: openeing a pdf with native pdf reader: openwithdefaultapplication
                  dinesena Level 1

                  Just to let everyone know. The answer

                  Rangora gave was the correct solution for my purposes. I actually found this link (below) a while ago which takes you through it and gave me some inspiration. Its a java hack and not the prettiest solution. Lets hope Adobe and Android provide something a little more useful in the future

                   

                  http://www.jamesward.com/2011/05/11/extending-air-for-android/

                   

                  This (above) is if you want to open local files with the native/default application. I actually managed to extend this and get it to open a file with its default application (not just pdfs, any type as long as the tablet has a software that can open/support the type)

                   

                  For the unitiated who have found this post: WebView is only good for loading webpages and pdfs wont load on HoneyComb devices this way. You can get PDFs to display in a browser with PDF plugin on Honeycomb devices, but only from a hosted file location (webserver) which wasnt any good for my purposes

                   

                  The link above is currently the only way to open local files with their default application

                   

                  Thanks to all for your participation