back-stack

WebView reloading when Fragment in ViewPager is retained form BackStack

老子叫甜甜 提交于 2019-11-28 23:08:02
Here is a code for a basic Fragment which contains a WebView . WebFragment.java public class WebFragment extends Fragment { String TAG = "WebFragment"; private WebView webView; private String currentUrl = "http://www.google.com"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.webview_layout, null); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); webView = (WebView) getView().findViewById(R.id.helloWebview); initWebView(); webView

Fragment methods: attach(), detach(), remove(), replace(), popBackStack()

十年热恋 提交于 2019-11-28 18:48:01
问题 I am very confused between these functions and their purposes. What I have observed that using replace() replaces the existing fragment with a new one. We can use addToBackStack(null) to put that fragment in back stack so we can go back to the previously shown fragment. Now when a fragment is added (or replaced) - onAttach() -> onCreate() etc.... methods of the fragment are called in order. Now when we call remove() on the fragment from our activity, which functions of the fragment are called

How to run an activity only once like Splash screen

拜拜、爱过 提交于 2019-11-28 09:27:52
In my app, I would like to run the Splash screen once at first run only but the problem is that I already placed in the Manifest this line: android:noHistory="true" which works great if I press back button and exits the app but note that the app is still in the background running, and when I press the app icon it goes back again to the Splash screen then my Registration page. I wanted to be redirected to the Registration page directly when I reopen my application. How do I do this? Thanks ahead for any suggestions. Akshay Mathur This is how I achieved it!Hope it helps! import android.app

Navigating back to FragmentPagerAdapter -> fragments are empty

无人久伴 提交于 2019-11-28 03:27:10
I have a Fragment (I'll call it pagerFragment ) that is added to the backstack and is visible. It holds a viewPager with a FragmentPagerAdapter . The FragmentPagerAdapter holds (let's say) two fragments: A and B. First adding of the fragments works great. Fragment A has a button that once clicked, adds a fragment (C) to the backstack. The problem is this: if I add that fragment (C), and then click back, the pagerAdapter is empty, and I cannot see any fragments inside. If I use a hack, and destroy the children fragments (A and B) in the pagerFragment s onDestroyView() , this solves the problem,

onCreate always called if navigating back with intent

时光总嘲笑我的痴心妄想 提交于 2019-11-28 03:26:12
问题 I have an activity called HomeActivity that has a SurfaceView and shows a camera preview picture. This activity is quiet heavy and feels slow if you are starting/restarting it. So I made some investigations and found out, that somehow always the onCreate method is being called. In my opinion this should not happen if the Activity has already been started? The documentation says : Called when the activity is first created. This is where you should do all of your normal static set up: create

Clear Activity back stack [duplicate]

岁酱吖の 提交于 2019-11-28 00:29:09
问题 This question already has answers here : Android: Clear the back stack (36 answers) Closed 6 years ago . I start from activity A->B->C->D->E ..when i go from D->E there should be no activity in stack but, the user can use back button from D and go to C (without refreshing Activity C, like normal back function) 回答1: You could add a BroadcastReceiver in all activities you want to close (A, B, C, D): public class MyActivity extends Activity { private FinishReceiver finishReceiver; private static

How to Reverse Fragment Animations on BackStack?

╄→гoц情女王★ 提交于 2019-11-27 17:45:53
I thought the system would reverse animations on the backstack when the back button is pressed when using fragments using the following code: FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out); ft.replace(R.id.viewContainer, new class(), "layout").addToBackStack(null).commit(); According to the android documentation for custom animation : Change: ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out); To: ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out, R.anim.hyperspace

How to persist fragment data after backstack transactions?

亡梦爱人 提交于 2019-11-27 16:28:29
问题 I've got an activity, containing fragment 'list', which upon clicking on one of its items will replace itself to a 'content' fragment. When the user uses the back button, he's brought to the 'list' fragment again. The problem is that the fragment is in its default state, no matter what I try to persist data. Facts: both fragments are created through public static TheFragment newInstance(Bundle args) , setArguments(args) and Bundle args = getArguments() both fragments are on the same level,

Android Reorder Fragment Backstack

寵の児 提交于 2019-11-27 13:14:06
I have a number of pages/fragments listed in my navigation drawer, the user is likely to switch between these frequently and I want them in the backstack so that they can navigate back, but I only want one instance of each fragment in the backstack so that the user doesn't not have to press back an insane number of times to exit the app. I can't figure out how to effectively 'reorder' the backstack' without pages getting removed. Currently when I change page I was using this code to change the fragment and make sure it's only in the back stack once if (mFragMgr == null) { mFragMgr =

Navigating back to FragmentPagerAdapter -> fragments are empty

偶尔善良 提交于 2019-11-27 05:07:56
问题 I have a Fragment (I'll call it pagerFragment ) that is added to the backstack and is visible. It holds a viewPager with a FragmentPagerAdapter . The FragmentPagerAdapter holds (let's say) two fragments: A and B. First adding of the fragments works great. Fragment A has a button that once clicked, adds a fragment (C) to the backstack. The problem is this: if I add that fragment (C), and then click back, the pagerAdapter is empty, and I cannot see any fragments inside. If I use a hack, and