private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("text/plain");
intent.addCategory(Intent.CATEGORY_OPENABLE); //안드로이드 4.4버전 (킷캣) 확인해볼 것 / 안된다 함
try {
startActivityForResult(
Intent.createChooser(intent, "Select a File to Read"),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
makeToastMsg("Please install a File Manager.");
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case FILE_SELECT_CODE:
if (resultCode == RESULT_OK) {
// Get the Uri of the selected file
try {
Uri uri = data.getData();
inputStream = getContentResolver().openInputStream(uri); //content:// 로 시작하는 uri는 절대경로로 변경할 수 없어 inputStream으로 받는다.
if (uri.getPath() != null) {
edImportPath.setText(uri.getPath());
}
Log.d("File uri", "File Uri: " + uri.toString());
// Get the path
String path = getPath(this, uri);
Log.d("File Path", "File Path: " + path);
// Get the file instance
// File file = new File(path);
// Initiate the upload
} catch (URISyntaxException use) {
use.printStackTrace();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
버튼 클릭 시에 showFileChooser가 실행되어 파일을 선택하는 파일 관리자(LG G5 android ver 6.0.1(마시멜로))가 실행되는데요
갤럭시 s4 android ver 5.0.1(롤리팝) 에서는 dropbox가 실행됩니다.
기본 어플로 지정되어 있지 않구요
G5에서처럼 파일을 선택할 수 있도록 하는 방법이 있을까요?
dropbox에는 아무것도 없습니다.