/** 调用文件选择软件来选择文件 **/
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, "请选择一个要上传的文件"), REQUEST_FILE_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Toast.makeText(ActivityMenu6_AddNew.this, "请安装文件管理器", Toast.LENGTH_SHORT).show();
}
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, "请选择一个要上传的文件"), REQUEST_FILE_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Toast.makeText(ActivityMenu6_AddNew.this, "请安装文件管理器", Toast.LENGTH_SHORT).show();
}
}
// 返回的数据
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
// Get the Uri of the selected file
Uri uri = data.getData();
fujianString = FilePath.getImageAbsolutePath(ActivityMenu6_AddNew.this,uri);
tv_attachment.setText(fujianString.substring(fujianString.lastIndexOf("/")+1));
}
}