Skip to content

Commit 7524176

Browse files
TomerPacificSwati4star
authored andcommitted
#784 - The context received in the onAttach method is not always an Activity context so a check was added to make sure that the correct context is being passed (#804)
1 parent d14e439 commit 7524176

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/src/main/java/swati4star/createpdf/fragment/TextToPdfFragment.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
454454
@Override
455455
public void onAttach(Context context) {
456456
super.onAttach(context);
457-
mActivity = (Activity) context;
457+
if (context instanceof Activity) {
458+
mActivity = (Activity) context;
459+
} else {
460+
mActivity = getActivity();
461+
}
462+
458463
mFileUtils = new FileUtils(mActivity);
459464
mDirectoryUtils = new DirectoryUtils(mActivity);
460465
}

0 commit comments

Comments
 (0)