简体   繁体   English

意图导航抽屉片段

[英]Intent to navigation drawer fragment

I have set android:launchmode="singletask" for my current project. 我为当前项目设置了android:launchmode="singletask" So I'm suppose to redirect from ActivityB.FragmentA to ActivityA.FragmentB. 所以我想从ActivityB.FragmentA重定向到ActivityA.FragmentB。

ActivityA.FragmentB is a fragment that is opened through navigation drawer. ActivityA.FragmentB是通过导航抽屉打开的片段。

So how do I intent to ActivityA.FragmentB? 那么我打算如何使用ActivityA.FragmentB?

In intent call from ActivityB to ActivityA pass a boolean and on basis of it in ActivityA open the fragment ; 在从ActivityB到ActivityA的意向调用中传递一个布尔,然后在ActivityA的基础上打开片段; pass false from elsewhere activityA is called. 从其他地方传递false称为activityA。

I used sharedpreferences to redirect it. 我使用了sharedpreferences来重定向它。

I set shared preferences when intent and get it while onResume(). 我在意图时设置了共享首选项,并在onResume()时获取了它。

SharedPreferences variable is deleted after that fragment is replaced. 替换该片段后,将删除SharedPreferences变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM