As stated, for example, I want to open word documents, wrote the following code directly, personally think that the following code is the default already have word software
private void startEditTemplate (String filePath) {
Intent intent = new Intent ("android.intent.action.VIEW");
intent.addCategory ("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile (new File (filePath));
intent.setDataAndType (uri, "application / msword");
ComposeMailActivity.this.startActivityForResult (intent,
REQUEST_EDIT_CONTENT);
}
However, if the software is not installed word of it, what will happen this code, the actual test is collapsed, what can distinguish whether the word install software? Is it only catch exceptions?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
By packagenamager first function to determine whether to install a word, if installed on startup, if not not send out intent
Reply:
You can test the file before opening it, if you already have the software to support the format specified. . .
Detailed consultation: getPackageManager () queryIntentActivities.. . .
Reply:
Moderators encountered the same problem I do not know there is no solution, if resolved, please let me know. . Thank you
No comments:
Post a Comment