So the first problem is that you're asking another app to open a file in your raw resources folder. For security reasons, this is not possible. The receiving app (Adobe Reader in this case) needs the file to be in a place that's not protected. You can copy it to the external public storage area and then open an intent on the copied file. Keep in mind that you should not do the copying on the UI thread and you shouldn't do it every time, only if the file doesn't exist.
The second problem is that you haven't specified a MIME type for the Intent. Make sure you set it to "application/pdf".
private void openPDF() {
final InputStream in = getResources().openRawResource(R.raw.english);
new AsyncTask<Void, Void, Void> () {
File outDir = new File(Environment.getExternalStorageDirectory() + "/" + getPackageName() + "/.temp");
File outFile = new File(outDir, "english.pdf");
@Override
protected void onPostExecute(Void result) {
Uri uri = Uri.fromFile(outFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
@Override
protected Void doInBackground(Void... params) {
if (!outFile.exists()) {
outDir.mkdirs();
OutputStream out;
try {
out = new FileOutputStream(outFile);
copyPDF(in, out);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
}.execute();
}
private void copyPDF(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}