インテントを使用してファイルを選択するアプリケーションを選択するには、「アクションを完了」を選択する方法(デバイス内のファイルをブラウズするアプリケーションがいくつかあるとします)インテントを使用してファイルブラウザを選択する方法
私は拡張子を使用してファイルをフィルタ処理したい...(例:。* .SAV、* .props)
あなたはこのようなものを使用することができ、事前に
インテントを使用してファイルを選択するアプリケーションを選択するには、「アクションを完了」を選択する方法(デバイス内のファイルをブラウズするアプリケーションがいくつかあるとします)インテントを使用してファイルブラウザを選択する方法
私は拡張子を使用してファイルをフィルタ処理したい...(例:。* .SAV、* .props)
あなたはこのようなものを使用することができ、事前に
ありがとう:
....
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, YOUR_RESULT_CODE);
....
を
Bあなたは、サードパーティ製のファイルブラウザをフィルタに設定できるのは本当に疑問です。 または、このファイルダイアログボックスを使用してみてください:http://code.google.com/p/android-file-dialog/
リンクをありがとう。:)本当にシンプルで便利なファイルブラウザ –
代わりに 'intent.setType(" */* ")'を使う必要がありました。私が知っているMIMEタイプは 'file /'で始まらない。 – Alicia
//ここでKITKATまたは新しいバージョンを確認すると、これもsamsungファイルの問題を解決します。
boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
if (isKitKat) {
Intent intent = new Intent();
intent.setType("*/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,FILE_SELECT_CODE);
} else {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(intent,FILE_SELECT_CODE);
}
if/elseのコードは同じことをしています – roplacebo
可能な場合、これはそうuがインストールされているファイルエクスプローラを選択するために、Uを聞いてきます、ビルドでファイルエクスプローラを開きます。
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
//intent.setType("*/*"); //all files
intent.setType("text/xml"); //XML file only
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show();
}
}
これは、ドキュメントのファイルを選択するためにあなたを助けることがあり、uはあなたの必要性
Intent intent;
if (VERSION.SDK_INT >= 19) {
intent = new Intent("android.intent.action.OPEN_DOCUMENT");
intent.setType("*/*");
} else {
PackageManager packageManager =getActivity().getPackageManager();
intent = new Intent("android.intent.action.GET_CONTENT");
intent.setType("file*//*");
if (packageManager.queryIntentActivities(intent,MEDIA_TYPE_IMAGE).size() == 0) {
UserToast.show(getActivity(), getResources().getString(R.string.no_file_manager_present));
}
}
if (getActivity().getPackageManager().resolveActivity(intent, NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST) != null) {
startActivityForResult(intent, UPLOAD_FILE);
}
訪問このスレッドごとにアクションを変更することができ、 http://stackoverflow.com/questions/5537907/view -file-path-in-a-file-manager-as-android-intent もし私が間違っていないなら、これはあなたを助けるかもしれません。 –