Tek*_*Yin 17 android android-intent
如何使用意图提示用户选择"完成操作"来选择应用程序来选择文件(假设有几个应用程序来浏览设备中的文件)
我想使用扩展名来过滤文件..(例如:*.sav,*.props)
先感谢您
Vya*_*kin 42
你可以使用这样的东西:
....
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, YOUR_RESULT_CODE);
....
Run Code Online (Sandbox Code Playgroud)
但我真的怀疑你可以设置过滤器第三方文件浏览器.或者您可以尝试使用此文件对话框:http://code.google.com/p/android-file-dialog/
小智 7
这将打开内置文件资源管理器(如果可用),否则将要求您选择已安装的文件资源管理器.
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();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
60923 次 |
| 最近记录: |