2016-04-11 16 views
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) {     
} 

任意のヘルプ

は事前

+0

「Intent intent = new Intent(Intent.ACTION_VIEW);」を使用してみてください。 –

+0

'path'の値は何ですか? 'type'の値は何ですか? – CommonsWare

+0

type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"およびpath = "/ storage/emulated/0/Download/ws.docx"ルートから取得するパス= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath (); – user173488

答えて

0

でのおかげで私は、私は、ファイルを追加する必要がありました、それを解決し、理解されるであろう。

path="file://"+Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOA‌​DS).getPath()+"/"+myFileName; 
関連する問題