getting result for startActivityForResult() in normal class
-
02-07-2021 - |
Question
I am working on saving PDF from internet. The class I am using, to download pdf is a normal class "FileChooser.java", not an activity class. Now, I want to open a Activity to browse through the SDCard and return the selected folder path to the "FileChooser" class
I have planned to use the following code
private void getFolder() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(
Intent.createChooser(intent, "Please select the folder"),0);
} catch (Exception e) {
e.printStackTrace();
}
}
but i want the result to be in "FileChooser" (Normal Java)class
What should i do, to get the result in "FileChooser" class?
Please guide me.
Solution
You can pass the data using setresult() and get the result by using onactivity result().
The tutorial here helps you.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow