Android 4.4 KitKat - How can I avoid the new file picker? - android

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!

Related

Intent-Filter for content:// URI on Android 9 and higher

I want to write intent-filter that will allow my app to open files with custom files exception. On Android 8 (and before) there was a possibility to do this as intent url was delivered like this (this comes from Chrome downloads screen):
content://com.android.chrome.FileProvider/downloads/somefile.xyz
Now, the same screen on Android 9+ delivers intent like this:
content://media/external/downloads/25
Is there a possibility to detect my file extension with such intent-uri format without writing an intent filter that just detects all intents (*)?
Any help would be appreciated!
Is there a possibility to detect my file extension with such intent-uri format without writing an intent filter that just detects all intents (*)?
No, sorry.
On Android 8 (and before) there was a possibility to do this as intent url was delivered like this
There is no requirement, on any version of Android, for a content Uri to contain a file extension, just as there is no requirement on the Web for an http or https URL to contain a file extension.
this comes from Chrome downloads screen
That may be true for a particular version of Chrome. Please do not assume that Chrome will always use a file extension. And please do not assume that every Android device user uses Chrome and only uses Chrome. There is no requirement for other apps to use a content Uri with a file extension.

Android PDF viewer app to be invoked

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);

How to Open Documents in Android

I am new to android programming, so i have a question regarding how to open any document such as .doc, .docx, .ppt, etc. in android. I also need to implement preview functionality, wherein the file should be downloaded temporarily and user can see the file opened just by a single click.
How does dropbox does this? Is there any intents available?
Can anybody help me out of this issue by some example or code?
Thanks.
Unlike iOS, Android itself does not support rendering .doc or .ppt files.
You are looking for a public intent that allows your app to reuse other apps' activities to display these document types. But this will only work for a phone that has an app installed that supports this Intent.
http://developer.android.com/guide/topics/intents/intents-filters.html
This may help: Android Launching an application chooser with appropriate list of applications

System call to open a pdf on Entourage eDGe's E-Reader

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.

is there a way to open and edit word file in android?

and if this application exist does it has an open API?
nop theres no API to support that, and this is the only way that I Know
Word, Excel, PowerPoint and Adobe PDF files on your Android-powered Smartphone
An app like QuickOffice or Documents To Go comes on every Android I've seen. If it already has the app then the following should work: Android Launching an application chooser with appropriate list of applications

Categories

Resources