简体   繁体   中英

Problems accessing a PDF file that is in the internal NETWORK in my android application

can someone help me ?

I have an android application that locates the file on the network and gets its URL.

This URL is passed as a parameter when calling the Adobe Reader, but it does not open the document.

The URL format is returning "http://192.168.1.1..........ex.pdf"

This is a code:

The variable DOC is a URL.

                    try {
                                Intent intent = new Intent();
                                intent.setPackage("com.adobe.reader");
                                intent.setDataAndType(Uri.parse(doc), "application/pdf");


                                startActivity(intent);


                    } catch (ActivityNotFoundException activityNotFoundException) {
                                activityNotFoundException.printStackTrace();


                                throw activityNotFoundException;
                    } catch (Exception otherException) {
                                otherException.printStackTrace();


                                throw otherException;
                    }
                }


                                    if(selectedDocumentURL.contains(".pdf"))
                                    {
                                              try {
                                                        loadDocInReader(selectedDocumentURL);
                                              } catch (ActivityNotFoundException e) {
                                                        // TODO Auto-generated catch block
                                                        e.printStackTrace();
                                              } catch (Exception e) {
                                                        // TODO Auto-generated catch block
                                                        e.printStackTrace();
                                              }
                                    }else
                                    {
                                    Intent showPic = IntentFactory.createShowPicture(
                                                        WorkOrderDocumentsTable.this, selectedDocumentURL);
                                    startActivity(showPic);
                                    }

                          } else {
                                    showDialog(getResources().getString(R.string.Atte ntion),
                                                        ((Exception) msg.obj).getMessage());
                          }
                          progress.dismiss();
                };
      };

Thanks !

Step #1: Delete intent.setPackage("com.adobe.reader"); .

Step #2: Make sure that the Web server is returning the proper MIME type for your request, as that may trump the MIME type you put in your Intent .

Step #3: Make sure that the device can reach this server in general (eg, via the browser app).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM