Android how to open a .doc extension file?

Narendra picture Narendra · Apr 20, 2012 · Viewed 60.8k times · Source

Is there any possible way to open a .doc extension file?

Answer

ρяσѕρєя K picture ρяσѕρєя K · Apr 20, 2012

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

or if you have installed some app then use this Intent:

//Uri uri = Uri.parse("file://"+file.getAbsolutePath());
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(Intent.ACTION_VIEW);
String type = "application/msword";
intent.setDataAndType(Uri.fromFile(file), type);
startActivity(intent);