I am trying to write an app that requires different PDF files to be opened and displayed on the E-Reader side of the eDGe's dual screens while the app is running on the LCD side. I've been using Better Terminal Emulator to cruise around the eDGe's file system but can't seem to find the command that opens PDF files. Does anyone know it or is there even one?
I'm going to answer my own question in case someone runs into the same issue. Using an intent with the action set as ACTION_VIEW, the mime type set as application/pdf, and a pdf file as the data, the Library will handle the intent.
Related
I'd like to generate a signed link via S3 and then allow a mobile user to download this file. So far this is going okay (downloads with the correct name, filesize, etc).
However - when it comes to opening it (even a .png), I get the message "Cannot open file" and it doesn't turn up in the device's photos, gallery, or anything like that.
Are there some kind of headers missing? Some extra bit of set-up?
The context is a React Native app where the user requests a file, opens the URL via Linking in Chrome, Chrome downloads it, and then they can open it properly. Ideally this will work for any file types (e.g. png, jpg, docx, pdf). Thanks!
If you can't do this in ReactNative, you can always leverage on a native picker. https://developer.android.com/guide/topics/providers/document-provider in any case, there are tons of information to open files in ReactNative with some extensions as: https://github.com/huangzuizui/react-native-file-opener. I tried a couple of them and they work. It should do the job, check the permissions in your application as well. It can be a headers problem so you need to check all of this.
I have an application which needs to ask the user for a file. I achieve it by starting an activity using an intent with Intent.ACTION_GET_CONTENT action and "file/*" MIME type.
It works fine on earlier android versions than 4.4. System shows the list of installed file managers, and my app gets a "file://" URL after I choose a file.
The problem comes when I run the app on KitKat. When the app wants to open a file on KitKat, the new built-in file picker shows up. It lists various sources to open a file, such as "Downloads", etc. But all files are greyed out. I can't open them. Ok, when I change MIME type to "*/*", it lets me open the same files. Then I open a file, and my application receives a "content://" style URL as result.
I know how to read data from those URLs, but it would be hard to rewrite the whole app to support it. It's a large one and was intended to work with files.
Is there any way to strictly define in the Intent that I want a "file://" url?
Or is there a way to prevent KitKat from using the new file picker framework? Is there any way to have it working in the same way as on earlier versions?
Can this problem be solved without implementing "content://"-style URL support in the app? Probably it would be the clearest solution...
Thanks in advance!
If you go to imgur.com from your Android device, click on Upload an Image and then on Touch here to select your images, the Android prompts you with a Choose file for upload with few options. The good thing about this picker is that even if there is no camera as an option (for older phones) you can start the camera from the Gallery application, take a picture and eventually select it from the gallery to be uploaded.
That works also for any file <input> on any website.
So my question is: how can I invoke that file picker and eventually get the path to the selected image in native Java app?
If possible I would like to filter it so it will prompt only for images and not audio files and I don't want to install any file managers since it's doable within the browser. It's hard to believe that is available only for the Browser.
I don't want to implement my own file browser or list the camera's folder within my app. I'm also just starting with Android so a complete example to get eventually the file path or an image would be awesome.
Based on the chooser that comes up, <input> would appear to be requesting an ACTION_GET_CONTENT activity, with a MIME type of */*.
If possible I would like to filter it so it will prompt only for images and not audio files
Use a MIME type of image/*.
I'm also just starting with Android so a complete example to get eventually the file path or an image would be awesome.
See: https://stackoverflow.com/a/10274699/115145
I need a pointer to a (preferably free) PDF viewer app that I can invoke on a file or URL link via a startActivity on an Intent. I know that there is no real standard - I have one phone that came with OpenOffice that can read local PDF files, and one phone that has no built-in PDF reader.
What I want is the name of an application that I can suggest to my users to download from the market that is a PDF viewer that I can invoke by configuring an Intent and calling startActivity. I would make this suggestion when I intercept a URL to a pdf file, and discover that the application is not yet installed. Although ugly, this is better than the blank screen they get now because the built in browser doesn't do PDF.
I already installed Adobe's PDF viewer but it is not showing up in the package manager as being a candidate to handle PDF files.
I have used the technique suggested in SO:how-to-render-pdf-in-android to examine the candidate activities for a URL based PDF link and a local file PDF link and see that the com.android.browser.Browser is always invoked for http:// URL links; a URL of "file.pdf" causes OpenOffice to be selected on one phone and nothing on the other phone. Adobe's PDF viewer is not a candidate for either approach.
I tried the Google Docs viewer approach (as suggested in SO:android-load-pdf-pdf-viewer but that leaves a lot to be desired, especially as the PDF image I tried to load kept moving further and further down the device's screen until a user would need to scroll several screen fulls of blank screen to get to the document.
I see libraries such as android-pdf-viewer as a potential solution. But I'd prefer to link to another application rather than build in PDF support (including the fonts, etc) into my application. This then allows my application to support multiple PDF viewer applications - choosing one that the user has already installed or suggesting my favorite one if no compatible reader is present when I need it. Potentially I could see using these types of libraries to create such an application and load it to the market place, but before doing that I want to make sure that I'm not re-inventing the wheel.
I found the droid-reader application which looks promising, but this doesn't appear to be available from the market place. While I'm personally comfortable with the gymnastics of downloading files to my sdcard and installing from there, its not a viable option for the general public user that I'm targeting.
I hope the following code snippit would be helpful to you for reading pdfs. It will use the default pdf viewer that has been set on your device.
Intent intent= new Intent(Intent.ACTION_VIEW);
File f = new File("/mnt/sdcard/file.pdf");
intent.setDataAndType(Uri.fromFile(f),"application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(intent);
My app has a string containing the URL to a file, typically something like a Word document or a PDF file. I want to give the user a way to download the file the same way they would if they had clicked on a link in the browser (letting the browser store it in the default location, etc).
At the moment I am doing this by launching an ACTION_VIEW intent. It works in most cases, but there are several problems with it. Often the browser window tries to display a message which for some reason immediately disappears and can't be read. Sometimes the download fails and I can't detect that. If it does succeed, all the user really sees is a small icon in the top status bar that they have to know to look for.
Is there a better way to do this? Some way to start a dedicated DOWNLOAD action instead of invoking the whole browser?
Could I download the file myself in my own code and then somehow cause it to end up in the same place as if the browser had downloaded it?
Thanks.
You can download it with your own code, and place it in the \Download folder on the SD card. Alternatively, you could use the DownloadManager available on API 9 and above.