I am working on pdf. I am trying to open a pdf file from my application using the code below. But I failed to open.
private void openPdf() {
File fi
I know maybe is too late for an answer, but your problem is cause by these 2 line:
intent.setData(path);
intent.setType("application/pdf");
When you setData and after that you setType, the second command will clean the path assingned in setData.
In this situation, you should use setDataAndType(path,"application/pdf")
/** * Set an explicit MIME data type. * *This is used to create intents that only specify a type and not data, * for example to indicate the type of data to return. * *
This method automatically clears any data that was * previously set (for example by {@link #setData}). * *
Note: MIME type matching in the Android framework is * case-sensitive, unlike formal RFC MIME types. As a result, * you should always write your MIME types with lower case letters, * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} * to ensure that it is converted to lower case. * * @param type The MIME type of the data being handled by this intent. * * @return Returns the same Intent object, for chaining multiple calls * into a single statement. * * @see #getType * @see #setTypeAndNormalize * @see #setDataAndType * @see #normalizeMimeType */ public Intent setType(String type) { mData = null; mType = type; return this; }
Javadoc Intent class