0
アプリケーションチューザを起動して任意のファイルを開くためのコードがありますが、これまでにファイルを開くときにメッセージファイルを開くことができません。 //パスの開始時にファイルを開くには: 私のアプリケーションから適切なアプリケーションがインストールされた適切なアプリケーションにAndroidのファイルを開く
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(path));
if(type.contains("image")) {
intent.setDataAndType(Uri.parse(path),type);
}else if(extension.equalsIgnoreCase("txt")){
intent.setDataAndType(Uri.parse(path),"text/plain");
}else{
intent.setDataAndType(Uri.parse(path),type);
}
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
Intent intentOpen = Intent.createChooser(intent, "Open File");
try {
activity.startActivity(intentOpen);
} catch (ActivityNotFoundException e) {
}
任意のヘルプ
は事前
「Intent intent = new Intent(Intent.ACTION_VIEW);」を使用してみてください。 –
'path'の値は何ですか? 'type'の値は何ですか? – CommonsWare
type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"およびpath = "/ storage/emulated/0/Download/ws.docx"ルートから取得するパス= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath (); – user173488