before
Intent intent;
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("text/plain"); // MIME type for text files
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, READ_REQUEST_CODE);
after : define resultLauncher and start
ActivityResultLauncher<String> mGetContent =
registerForActivityResult(new ActivityResultContracts.GetContent(), new ActivityResultCallback<Uri>() {
@Override
public void onActivityResult(Uri uri) {
fileUrl = uri;
where = readTextFileContent(uri);
show_file();
}
});
mGetContent.launch("text/plain");
'android source ' 카테고리의 다른 글
code page 설정하여 파일 읽고 쓰기 (0) | 2024.08.08 |
---|---|
Wifi Monitoring (0) | 2024.07.02 |
image 를 rounding 으로 표시 (0) | 2024.04.28 |
Menu icon 간격 적게 하는 법 (0) | 2024.04.26 |
text prompted box input (0) | 2024.03.28 |