Each set of changes is committed together as a single unit called a FragmentTransaction . An intent can contain data via a Bundle. Oct 17, 2016 · If using Kotlin, and android navigation architecture, you can use like this, from Navigation 2. bundle. CategoryRowFragment fragment = new CategoryRowFragment(); // pass arguments to fragment. id. xml); StartActivity(i); Oct 3, 2018 · If we can't use safeargs library by some reasons, we can pass data also inside Bundle. – Jul 4, 2013 · Android studio will prompt you to implement method of interface in fragment. I had forgotten it when I ended up here. Feb 28, 2018 · From the android documentation: Of course, the activity that responds must be designed to return a result. If the Fragment needs to pass on a result, it can access its Activity and set its result and finish it. this, SomeFragmentActivity. Nov 23, 2016 · 6. Of course, the activity that responds must be Apr 12, 2018 · 6. Feb 11, 2015 · Since Activity gets the result of onActivityResult(), you will need to override the activity's onActivityResult() and call super. Your activity receives it in the onActivityResult() callback. If you want to get the correct resultCode in your activity try this: Change: startActivityForResult (intent, 1); To: getActivity (). The newInstance method is created in the fragment but is never called so can't be used to pass arguments. Overview; Interfaces. RESULT_OK, resultIntent);. Step 4: Create a class for the custom fragment (MyCustomFragment. Now in the previous activity lets say . e. Feb 15, 2012 · What I am using to find current displaying fragment is in below code. The fragment’s view hierarchy becomes part of, or attaches to , the host’s view Jun 22, 2020 · Google has just added a new ability to FragmentManager which made the FragmentManager be able to act as a central store for fragment results. requestPermissions in a fragment, the onRequestPermissionsResult callback The easiest way to communicate between your activity and fragments is using interfaces. private ActivityName mActivityName; and get it like this inside your fragment function named as "onCreateView". If you create a fragment in Android Studio using one of the templates e. planList. g. So even if you are passing the result it will not come in fragment as onActivityResult never executes. // Stuff to do, dependent on requestCode and resultCode. According to this, I'm trying to transfer the file via onActivityResult() to the fragment A. 2. Dec 25, 2017 · Just create a method in fragment refreshList. So, here, you can't track the request code. Step 1 to pass data from Fragment to container activity you have many ways; the one I usually use is to use an Interface: Create interface for ActivityB. As per the Fragment Result API guide: If you call setFragmentResult() more than once for the same key, and if the listener is not STARTED, the system replaces any pending results with your updated result. 3. 5 with ease, first, there should be an activity where you are coming to get result . Dec 29, 2013 · On the third fragment I have a button starts a new activity through intent. c. profile_fragment. void doSomethingInFragment() {//Add your code here } Final part part listener instance to activity like this in fragment onCreate method ((ListnerActivity) getActivity()). ACTION_GET_CONTENT in a fragment B into a DialogFragment, and transfer it to a fragment A which is not a part of the DialogFragment. setArguments(args); return f; In Fragment get by using this method. Implement that interface in Fragment A then pass the reference of that interface in BottomSheetDialog, when you are changing the date, in that method call that interface method and pass your date in method parameter. const val ARG_TEMPLATE_CODE = "templateCode". and then when you want to pass data back to fragment B from C, you can call the following code: getTargetFragment(). On the other side, your Activity can always search for a fragment using getFragmentManager(). Aug 8, 2021 · In my project, it is fragment > dialogfragment > previewactivity > videoviewer. – Däñish Shärmà. So, you can't track from who this result is from. PromoCodeDialogFragment dialog = new PromoCodeDialogFragment(listener); dialog. answered Dec 27, 2018 at 11:08. Feb 22, 2017 · In case of fragment, write getActivity() to get activity context instead of giving the name of activity explicitly. Aug 19, 2020 · 2. It simplifies the process of starting an activity and handling the result, as compared to the traditional approach i. this); DONE!!. So you can use it exactly as in an Activity: public class YourFragment extends Fragment {. As an Android developer, we all should be familiar with the startActivityForResult function. Fragment newFragment = FragmentA. void setDataAAndFinish(whateverType data); There is a much simpler way to receive a result from a DialogFragment. getParentFragmentManager() alongside Fragment. getTargetRequestCode(), Activity. getId()) {. Get the latest; Stay in touch with the latest releases throughout the year, join our preview programs, and give us your feedback. at the time , every time checking the condition and get the fragment and pass the value is quite disgusting. putParcelableArrayList("valuesArray", (ArrayList<Hospitals>)result); GmapFragment gmapFragment Dec 8, 2014 · ImageButton click ImageButton onClickListener called startActivityForResult onActivityResult of the activity it is in, of the dialog fragment it is in, of the fragment itself is called onResume of the called activity is called called activity does. putString("data", data); f. In this example MainActivity will start a Sep 3, 2021 · Well the only solution I found was to use an activity, it seems that when using registerForActivityResult it returns me to the activity, not the fragment, so if you were in a fragment that wasn't the activitie's main/default you won't be able to return to it, the function will return you to the main fragment for the activity since it's technichally opening a new intent to get the information 1. Feb 17, 2023 · Step 3: Add EditText, Button, and Frame in the layout file (activity_main. public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {. We continue the story about the Jetpack library’s latest updates that are designed to simplify data exchange between different parts of Android apps. To pass data from Fragment to Activity 2, I'd suggest to use some interface like Jan 3, 2021 · Check that fragment where you listen for fragment result and fragment where you set the result are in the same fragment manager. t. We use this function for starting a new Activity and getting results back to current the Fragment or Activity. Bundle bundle = new Bundle(); // event list we want to populate. I suppose the issue now is how can I get the result through multiple activities. class); intent. Jul 31, 2020 · In this article, we created a custom contract, but the Activity Result APIs provide default contracts for basic intents actions like taking a picture, requesting permissions e. . Option 3: Jan 3, 2024 · Use the FragmentManager. Try to change the line with mListener: mListener= (Listener)activity. Jan 12, 2013 · You should start by reading the Android developer documentation. getSupportFragmentManager() or Fragment. Feb 27, 2022 · That is, the dialog can be opened inside the fragment in different cases. The supportFragmentManager has findFragmentById() and findFragmentByTag() methods that you can use to get a fragment instance. To create a minimal fragment that defines its own layout, provide your fragment's layout resource to the base constructor, as shown in the following example: Kotlin Java. For example, suppose you have a Fragment class named FirstFragment created in your activity Feb 17, 2021 · 5. Mar 22, 2023 · A Fragment represents a reusable portion of your app's UI. 0 and Fragment v1. When in AppCompatActivity, you should use ActivityCompat. get Dec 16, 2016 · To pass data from Activity 2 to Activity 1 you can use startActivityForResult() in Activity 1 to start Activity 2, and onActivityResult() in Activity 1 to receive that data. Fragment, you should use simply requestPermissions (this is an instance method of android. I tell you one. Or, you might start the People app in order for the user to select a contact and you'll receive the contact details as a result. permission. And I need to distinguish between these cases. setArguments(b); return f; In order to start the fragment from the class, you can do the following. Jun 6, 2016 · You can't call Fragments via Intent. onAttach(activity); From Search screen I set result and send to the previous screen. Fragment class. In this example MainActivity will start a Jan 10, 2015 · 1. Create one interface. class); startActivity(intent); From an Activity. Below Kotlin code, get bundle argument from source fragment. Now i have to pass the result to Fragment A. At runtime, the FragmentManager can perform back stack operations like adding or removing fragments in response to user interactions. userList. One thing i don't wanna do is to create a private instance of Fragment A in Activity and call it's method. Starting a Fragment for a result doesn't make much sense, because the Activity that houses it always has access to it, and vice versa. public void refreshList(List<Suser> userList){. To do this, I send a different request key to the dialog fragment. Then in the Fragment 's onCreateView, connect the variable to the Activity and then you have a reference that you can use to get any public variable in the MainActivity. Using Kotlin, you call requestPermissions(arrayOf(Manifest. Code snippets at that webpage for your HomeFragment: public static class MyFragment extends Fragment {. Intent intent = new Intent(Activity. Mar 18, 2013 · From a Fragment: Intent intent = new Intent(getActivity(), mFragmentFavorite. onActivityResult() to propagate to the respective fragment for unhandled results codes or for all. java (page 1) + including the intent launch To receive a result, call startActivityForResult() (instead of startActivity() ). putExtra("datafrom C", "datafrom C") ); and get it from the onActivityResult () method in your fragment B: @Override. So if your want to pass the result using onActivityResult then it will not execute that method. To solve this, make sure your ListAdapter has a reference to the fragment and use fragment. Fragment classes implement the ActivityResultCaller interface to let you use the registerForActivityResult () APIs. Set result on Fragment B: findNavController(). Change you Matisse call from Matisse. getSupportFragmentManager(). requestPermissions; When in android. newInstance(objectofyourclassdata); However, the data class must be parceable or serializable. However, before invoking the fragment, the request code is As Steve writes, a fragment should be modular. from(this), because looking at the source code of Matisse it also supports Fragment context. Likewise, child fragments must be stopped before their parent fragment or activity. navigate(R. String>, grantResults: IntArray): Unit {. Mar 17, 2021 · In 2020, Google finally introduced a solution to the old problem — the Activity Result API, a powerful tool for exchanging data between activities and requesting runtime permissions. override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out kotlin. Aug 6, 2021 · Bundle args = new Bundle(); args. getActivity(). putString("area", areastring); f. Alas, this flow is not correct as I want the user to have a preview of the task before starting it. Fragment is a part of an FragmentActivity. I shall update my post. findFragmentById(r. RESULT_OK, returnIntent); finish(); So that in onActivityResult I get the the result and set in the search field. class); Oct 15, 2017 · Your class should first implement Parcelable : Then implement the methods of Parcelable. Using the second solution you should get your onActivityResult callback in the fragment and you won Aug 20, 2016 · I have Activity A: is main activity for add product, user when click the text view (selectCategory) this activity show to user activity B which content fragment Bb(all type of Category), when user clicks in some of this categories, the app going to show user activity C which has fragment Cc (subcategories). So there is no need of using startActivityForResult and onActivityResult anymore. Instead of using LocalContext. Get one of our Figma kits for Android, Material Design, or Wear OS, and start designing your app's UI today. mVehicleNumber = mVehicleNumber; return dialog; this. Like Mar 19, 2016 · FragmentA f = new FragmentA(); Bundle b = new Bundle(); b. . Now I changed Search activity to Fragment. public void onAttach(Activity activity) {. CharSequence mLabel; Receiving the result can be done using the Fragment's method onActivityResult(). getBackStackEntryCount(); Fragment frag = fragManager. I am unable to get the instance of Fragment A. trim()) Navigation. root). As for example code, the Android SDK provides good examples. // in fragment. I have some criteria. A fragment defines and manages its own layout, has its own lifecycle, and can handle its own input events. File > New > Fragment > Fragment (List), then the fragment is linked via XML. I have coded for pick the file from intent. If you use startActivityForResult() and override onActivityResult(), Activity A will be able to get a result from Activity B, but it will not be able to get a result from Activity C. However, this means that the communication should not go through any activity but stay within the fragment. Although, if I remember correctly, onActivityResult() will get called on whatever started the activity for result. The most common ones are as follows: onCreateDialog() : override this callback to provide a Dialog for the fragment to manage and display. May 27, 2011 · Since Activity gets the result of onActivityResult(), you will need to override the activity's onActivityResult() and call super. For the Activity, search text for "Fragment newFragment = MyFragment. I have faced lot of issue when I try to get result from activity to fragment. If above 2 options do not work, then refer option 3 as it will definitely work. public void onActivityResult(int requestCode, int resultCode, Intent data) {. findFragmentByTag("fragmentA") or findFragmentById("FragmentA"). OnActivity result means it has to give a resultant view when prompted. val bundle = bundleOf("mobile" to binding. – Mar 19, 2014 · 1. Jan 3, 2024 · Get results using the Fragment Result API. You need to make sure that the Fragment's parent Activity also overrides onActivityResult() and calls it's super implementation. 0, the new Activity Result APIs have been introduced. If above two options do not work, then refer to option 3 as it will definitely work. constant in companion object of DetailFragment ( static final field in Java) Now you can pass data this way: val args = Bundle() 1. previousBackStackEntry?. Into the Fragment: @Override. The idea is basically to define an interface inside a given fragment A and let the activity implement that interface. putExtra("web_url", "url"); startActivity(intent); Jun 14, 2020 · The idea is to get a file from the Intent. action_nav_register_to_nav_verify_otp, bundle) Step-4. result. Intent result = new Intent(); ArrayList<ContactData> resultList = contactsAdapter. your BandasFragment will be like this: Nov 11, 2013 · Generally OnActivityResult does not execute in Fragment. e simply cast the result into ArrayList<Hospitals>: Bundle bundle = new Bundle(); bundle. newInstance ("From Arguments")". public static final int REQUEST_CODE = 1; Call your custom dialog activity using intent. That way the Fragment isn't tied to any specific Activity keeping it reusable. Suppose you have added. setActivityListener(SomeFragment. In Activity A : Launch Activity B, eg: if you using a Button View onSetClickListener Oct 2, 2012 · Also there is no method called getActivity in the FragmentActivity class. For example, you might have a fragment that reads QR codes, passing the data back to a previous fragment. this. RESULT_OK, new Intent(). In this Jun 19, 2017 · you can call onActivityResult inside a Fragment in android studio 3. Now you have your date in Fragment A use it. Sep 3, 2021 · Well the only solution I found was to use an activity, it seems that when using registerForActivityResult it returns me to the activity, not the fragment, so if you were in a fragment that wasn't the activitie's main/default you won't be able to return to it, the function will return you to the main fragment for the activity since it's technichally opening a new intent to get the information 1. Dec 23, 2019 · Step-3. Once it has implemented that interface, you could do anything you want in the method it overrides. Mar 14, 2016 · This is a common mistake that people make when coding for marshmallow. If I got that right then the key element that seems to be missing here is that you are expecting Activity1 to get a result from Activity3 even though it was Activity2 that started it for result. For example, your app can start a camera app and receive the captured photo as a result. And the first thing in brackets is the name of your Listener, for example, NewPlanNameListener. You need to send the data from the dialog back to the activity via a callback method, then have the activity give that data back to the fragment you want it to go to. class); startActivity(intent); If you want to start aFavorite instead of mFragmentFavorite then you only need to change out their names in the created Intent. It runs in the activity which holds the fragments. current to navigate to another Activity from a Composable you can pass the onClick callback to Activity / Fragment and navigate like before. If I do this inside the onCreate() method. v4. In kotlin. putSerializable("eventsList", eventsList Apr 12, 2022 · To get the current fragment that’s active in your Android Activity class, you need to use the supportFragmentManager object. By using startActivityForResult(Intent intent, int requestCode) you can start another Activity and then receive a result from that Activity in the onActivityResult(int requestCode, int resultCode, Intent data) method. So inside your A (or B) class you could use this code snippet to get the activity instance: Activity test = (Activity) this; But if your B class extends Fragment then the getActivity call would have worked. initiliaze this variable inisde your fargment class. , startActivityForResult(). But how do I, when receiving a result in a fragment, distinguish this result by key. Activities can only receive results from activities they have started directly. Android will invoke onActivityResult in your fragment. Caution: Avoid using the <fragment> tag to add a fragment using XML, as the <fragment> tag allows a fragment to move beyond the state of its FragmentManager. Dec 30, 2014 · In your fragment (F) call the startActivityForResult () method to start the activity A, then override onActivityResult () method in the fragment. You are calling startActivityForResult () from your Fragment. When you use the Navigation Component, the previous fragment is stopped when you navigate to a new fragment. Fragment) If you call ActivityCompat. answered Jul 28, 2021 at 14:48. After debugging the value i got from onActivityResult is null. setResult(Activity. and selected file to be passed to particular fragment for further process. registerForActivityResult(<your_contract>, <your_callback>); Feb 19, 2012 · button. This method should take back from new Activity to the fragment from the Activity was launched and this method should be in the Activity after the onCreate method May 16, 2019 · As you can see, you can capture the activity result on the Host activity. items; If your fragment is under the same activity where you want to send data then just make a new method or update your Registrar method in your activity and your fragment is part of this activity already so just access this method in fragment and pass your value via method. mActivityName = (ActivityName) getActivity(); edited Dec 27, 2018 at 11:35. It is simple and it works for me by now. REQUEST_GALLERY_CODE); Edit2. onDismiss() : override this callback if you need to perform any custom logic when your Dialog is dismissed Jul 16, 2021 · Here is the Java Code version - Using ActivityResultLauncher. May 29, 2024 · To create a fragment, extend the AndroidX Fragment class, and override its methods to insert your app logic, similar to the way you would create an Activity class. but it will be useful for future readers. EDIT. In some cases, you might want to pass a one-time value between two fragments or between a fragment and its host activity. first is an activity and the other is a fragment in the second activity All of the Fragments live inside Activities. I want let you know that this can be implemented in many ways. app. Alex Riabov. I have multiple fields in this screen. super. To pass the list to the fragment, write this code in your activity i. from(getActivity()) to Matisse. so , i have May 23, 2022 · I have a fragment (page 1) which contains a button that opens an activity (page 2) using activityLauncher so it returns a result, and within that same activity, a button for the exact same purposes (page 3). i have updated the codes above, I have faced lot of issue when I try to get result from activity to fragment. set("key", result) Observe the result on Fragment A, with same key: Mar 21, 2014 · I have tried out the codes in my colorActivity but it seems like the value didnt get passed through using setResult(Activity. That new activity is a QR scanner so it basically calls the camera and waits until camera finds appropriate and valid QR code. In your fragment onClick () call the activity like this. May 31, 2021 · 2. The most proper way is to make your Activity implement an Interface and use listeners. Sending data from Activity into Fragments linked by XML. Oct 2, 2017 · After that, add an OnSubmitClickListener to your dialog and add it to the constructor. May 2, 2012 · startActivityForResult(i, LAUNCH_SECOND_ACTIVITY); In your SecondActivity, set the data which you want to return back to FirstActivity. Feb 2, 2017 · Now you can call your Activity from fragments. now you can call fragment method from activity. Common case where this would happen is if you are using Activity. Until now, I have tried: using a view model but the live data stays null, Mar 31, 2016 · I have to call a method of Fragment A after getting result from Fragment B. mHeader = mHeader; dialog. frag); Mar 11, 2018 · For sending data from activity to another activity's fragment call a normal intent with bundle value, In another activity check on getIntent() and call a method from that fragment Intent intent = new Intent(this, MainActivity. public interface IActivityB {. Intent intent = new Intent(this, mFragmentFavorite. MyFragment mf = (MyFragment)getFragmentManager(). The FragmentManager manages the fragment back stack. If you don't want to return back, don't set any. How do I get the result back to my fragment? My button's onClick method which located in onCreate method in Fragment3 which extends Fragment class: Nov 11, 2018 · After spending hours of research I finally solve this problem as follow: As I have two nested fragments as child and parent in a one activity and I design to take action on each item click on the recyclerView items and going to another activity to get the result back and refreshing the list I added this code in MainActivity: Dec 17, 2016 · Activity2 starts Activity3 for result; Activity3 returns a result; Activity1 is expected receive Activity3's result. One option is to chain your activity results together. listener= listener; switch (view. May 29, 2014 · I just make an Onclick method to the button . Option 3 : Apr 19, 2018 · The easiest way, in my opinion, is to pass the data from Fragment inside B to ActivityB, then from ActivityB to ActivityA. The first part was about data transfer Dec 23, 2019 · Shift your onActivityResult code logic from your AddMessageFragment to MainActivity. You have onRequestPermissionsResult in Fragment as well. If it can find your Fragment, Then it can cast it into your FragmentA class and call its methods. kt) This is a custom fragment class to inflate the custom layout in the frame layout present in the main activity. Jan 16, 2013 · ORIGINAL ANSWER. With the Activity Result APIs which is strongly recommended by the documentation, I get that I should make prepareCall() before ActivityResultLauncher and to make sure the activity is in created state when I launch, but I still don't understand how to handle multiple activity results gracefully (at least, in one place) like in onActivityResult(). findFragmentById (int RESOURCE); where the last thing in brakets is the id of your fragment in main activity, for example, R. Finally I found below solution. In other words your B class is extending an Activity instance. 9,035 5 49 48. All in all Fragment is a content not container, so you need to create a FragmentActivity and add Fragment (Fragment1) in that, and then call on your onClick (), Intent intent = new Intent(MainActivity. savedStateHandle?. For example, if you want to open SecondActivity from a fragment, Intent intent=new Intent(getActivity(),SecondActivity. Oct 25, 2012 · In your Fragment, define a variable that would reference the parent Activity. Aug 21, 2018 · If you want listen in Activity then call like. onActivityResult(. First, in your Activity, Fragment, or FragmentActivity you need to add in the following information: @Override. After understanding your requirement. the code is below:I made onclick method clickForFriends in Button and Id is backFriendsList, And I use android. For example: In SecondActivity if you want to send back data: Intent returnIntent = new Intent(); returnIntent. support. When you do this, the requestCode is changed by the Activity that owns the Fragment. May 11, 2015 · Search text for "static MyFragment newInstance", is a good example. startActivityForResult(). So when the activity A finishes you can get get the result bundle in onActivityResult () method. Then the result will come back to the fragment's onActivityResult(). private DashboardViewModel dashboardViewModel; private static final int REQUEST_CODE_LOCATION_PERMISSION = 1; private TextView txtLocation; private ResultReceiver resultReceiver; private Activity activity = getActivity(); public View onCreateView(@NonNull LayoutInflater May 12, 2012 · 919. getFragments(). activity. When it does, it sends the result as another Intent object. In side the fragment , I created ActivityResultLauncher. protected void onActivityResult(int requestCode, int resultCode, Intent data) {. If you still want to have onRequestPermissionsResult centrally in your Activity, you need to call the method of Fragment onRequestPermissionsResult of your Activity. startActivityForResult (intent, 1); edited Apr 15, 2015 at 21:00. Just a quick example: public void datFromDialog(String data){. Fragments can't live on their own. class); startActivityForResult(intent , REQUEST_CODE); Now use onActivityResult to retrieve the result. findNavController(binding. setOnClickListener { val result = "result" // Use the Kotlin extension in the fragment-ktx artifact setFragmentResult("requestKey", bundleOf("bundleKey" to result)) } In the host Activity: To receive a fragment result in the host activity, set a result listener on the fragment manager using getSupportFragmentManager(). You can learn Dec 1, 2020 · 5. However, the request code is not longer that one you set (0). May 23, 2017 · 2. putExtra("result",result); Feb 9, 2013 · As in Activity v1. Or another way directly you can use this extras value by parent activity object in fragment or pass the arguments object directly inside constructor of fragment when create and then use in fragment. Jul 19, 2011 · @MuhammadBabar: You can try executePendingTransactions() on FragmentManager after calling commit() on the transaction, though I have not tried this. I have created an interface in Fragment B and implemented it in Activity. THE_PERMISSION_CODE_YOU_WANT), PERMISSION_REQUEST_CODE) and add the following override to your fragment. So Jan 3, 2024 · A DialogFragment follows the standard fragment lifecycle, with a few additional lifecycle callbacks. Here is an example: class MainActivity : ComponentActivity() {. text. Also, other answers here give you short snippets of sample code to use. FragmentManager fragManager = this. etMobileNo. i have many fragments having the functionality of File picking. To pass an object to a fragment, do the following: First store the objects in Bundle, don't forget to put implements serializable in class. startActivityForResult(intentGallery, SpotCuesUtils. getSupportFragmentManager(); int count = this. Below Kotlin code, pass argument to destination fragment. Specifically the topic of your question is covered in the Starting Activities and Getting Results section of the Activity documentation. 0-alpha02 release. Oct 5, 2012 · This answer may be too late. getFragmentManager (). addAll(userList); notifyDataSetChanged(); } Keep a global reference to fragment instance and invoke refreshList from where you receive the response. clear();// empty list. private final ActivityResultLauncher<input_type> mActivityResultLauncher =. Or you can use setContentView() to use a layout file with a <fragment> tag. I removed previewactivity from the flow and it worked. The result will be returned as an Intent. androidx. The other important part of the interface Sep 24, 2023 · The ActivityForResultLauncher is called when we call the launch() method on the activity. They must be hosted by an activity or another fragment. Here is part of my code: public class DashboardFragment extends Fragment {. The Activity Result APIs provide components for registering for a result, launching the result, and handling the result once it is dispatched by the system. Jan 3, 2024 · For example, a parent fragment or activity must be started before its child fragments. So I search from the search activity and set in this fragment. This method is used to start the other activity to receive a result back from the other activity. toString(). this, CustomDialogActivity. @Override. getChildFragmentManager(). xml) Refer to the comments inside the code for better understanding. Just pass your Fragment instance in BottomSheetFragment when you open it. ll lu zt jh md fu ob kj je ty