back-stack

NullpointerException on Backstack

旧城冷巷雨未停 提交于 2019-12-13 00:16:16
问题 I use API Level 16, in i try to replace some Fragment below some Tab where already is some Fragment. I cant really find a reason why, but sometimes i get an Exception like this: E/AndroidRuntime(27395): java.lang.NullPointerException E/AndroidRuntime(27395): at android.app.BackStackRecord.run(BackStackRecord.java:604) E/AndroidRuntime(27395): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1399) E/AndroidRuntime(27395): at android.app.FragmentManagerImpl$1.run

Android app closes when back button pressed

南楼画角 提交于 2019-12-13 00:14:08
问题 I have the following activity which launches a fragment when the tab is selected: public class MainActivity extends Activity implements TabListener { Fragment f = null; ..... public void onTabSelected(Tab tab, FragmentTransaction ft) { ..... if (tab.getPosition() == 0) { if (initalSync == true) { progress1.setVisibility(TRIM_MEMORY_UI_HIDDEN); } f = new EventFragment(); Bundle data = new Bundle(); data.putInt("idx", tab.getPosition()); f.setArguments(data); } if (tab.getPosition() == 1) {

Managing Action Bar titles when using fragments and the backstack

社会主义新天地 提交于 2019-12-12 15:40:59
问题 My app has an activity which uses the FragmentManager to push and pop fragments onto the backstack. However, when the backstack has 2 fragments and the last fragment is popped, I do not how to detect this to set the title of the Action Bar appropriately. I was hoping there was some method on a fragment I could override to determine when it becomes visible, but none of those suggested e.g. uservisiblehint, onHiddenChanged, etc. are called. How can I either: • determine when a fragment becomes

Can I put a fragment on Backstack which hasn't been initialized yet?

一个人想着一个人 提交于 2019-12-12 05:48:59
问题 I want to remove a fragment from backstack and put another fragment in its place which hasn't been created yet. Below is a picture of what I want to achieve. Is there any way to accomplish this? EDIT: As pointed out by @Elltz, it's not possible. So my question becomes Is it possible to destroy the last fragment from back stack? Can I handle the back button pressed manually to provide a different fragment than what is on the back stack? 回答1: NO ! NO ! NO ! want to remove a fragment from

Customize back navigation

天大地大妈咪最大 提交于 2019-12-12 04:20:41
问题 First of all I read this article but is kind of complicated for me . All I need is to go to an activity I want (navigate if exist in back stack or start it with Intent if it's not ) in onBackPressed() override . should I manage back stack or something else ? if yes how ? and if no what is a simple way for that ? P.S : I dont use ActionBar 回答1: you should override the second activity's onBackPressed() method and add android:launchMode="singleInstance" to your first activity in AndroidManifest

How to enable the home button to return to a common activity?

陌路散爱 提交于 2019-12-12 01:22:50
问题 I use ActionbarSherlock and would like to enable the home button ... Therefore I call setHomeButtonEnabled(true) in my base activity. public class BaseFragmentActivity extends SherlockFragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_Sherlock); super.onCreate(savedInstanceState); getSupportActionBar().setHomeButtonEnabled(true); // Here } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case

Android BackStack clear but keep root

不羁的心 提交于 2019-12-11 21:56:55
问题 I am currently writing a chat app. It is basically very similar to WhatsApp: On Startup there is last conversation overview. When I want to start a new conversation with somebody I have to do/pass last conversations overview activity (click on + to look for conversation partner) courses activity (choose a course) course participants activity (chooser partner) Conversation Activity So that is Basically the stack: [A1, A2, A3, A4] Now the user had a nice chat with some course member and wants

Manage the backstack in android

老子叫甜甜 提交于 2019-12-11 14:03:25
问题 Currently the structure of the android app is Home About us Products product1 product2 product3 Contact us As there is a side-menu and I can access the product 1 directly, My current attempt is add to backstack for every transaction,and it has a behavior that is quite strange If I go into like this: Home->product1->About us The flow is after I enter the home page, I click on the product1 on the side menu, after enter product1 page click on the about us on the side menu 1st time press back

Android Fragment onBackPressed display alertDialog

喜欢而已 提交于 2019-12-11 10:26:26
问题 I'm currently using Fragment with Backstack. In one of the fragment e.g " Menu " I wanted to prompt an alertdialog when user tapped on back button. But I'm having some problems in achieving that. I listed two scenario below that I tried. Scenario 1: I added a KeyListener in the " Menu " fragment that will trigger when user tapped on back button. I add another fragment on top of " Menu " called " Report ". When I pressed back button in " Report " fragment it will still prompt out the

Need single activity in new task backstack

帅比萌擦擦* 提交于 2019-12-11 09:28:55
问题 It is nightmare when must deal with android task and launching modes(flags). Need accomplish this scenario: From background service launch Activity[1] that belongs to App[A] in new task. When user go [back] - finish activity[1] and resume whatever App was previously in foreground! If App[A] was active and running - there is no problem, [beck] close Activity[1] and resume App[A]. But if any other App[B] is in foreground at the moment when launching Activity[1] (even with the new Task) all App