android - Different backstack behavior between Nexus 6 device and emulator -


i working on app has support fragment searchview widget , recyclerview present search results sends user fragmentactivity display details of selection. of works fine, i'm seeing inconsistent behavior between nexus 6 emulator , actual device in regards backstack. in emulator, works expect, user being taken search results fragment if pressing button while on details fragmentactivity. on actual nexus 6 device, user taken way appcompatactivity contains app's menu (this activity uses support fragmentmanager, adds fragments manages backstack):

private void replacefragment(fragment supportfragment) {     string fragmentname = supportfragment.getclass().getsimplename();     supportfragmentmanager.begintransaction()             .addtobackstack(fragmentname)             .replace(r.id.frame_menu_container, supportfragment, fragmentname)             .commit(); } 

the code send user fragment fragmentactivity intent extras:

intent intent = new intent(getactivity(), playerdetailsactivity.class); intent.putextra(transientplayer.bundle_key, transientplayer); startactivity(intent); 

i not doing special backstack (yet) - default behavior.

what issue here? i've done reading on backstack , haven't seen yet on manually adding backstack when you're going fragmentactivy fragment you're not using fragmentmanager.

edit 1: here's layout xml frame_menu_container defined:

<relativelayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:gravity="center"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.v7.widget.toolbar         android:id="@+id/toolbar"         android:layout_width="match_parent"         android:layout_height="?attr/actionbarsize"         android:background="?attr/colorprimary"         android:theme="@style/themeoverlay.appcompat.dark.actionbar"         app:popuptheme="@style/themeoverlay.appcompat.light"/>      <framelayout         android:id="@+id/frame_menu_container"         android:layout_below="@id/toolbar"         android:layout_width="match_parent"         android:layout_height="match_parent"         tools:layout="@layout/fragment_home">     </framelayout>  </relativelayout> 

edit 2: ok, here textual description of high-level activities , fragments:

navigationmenuactivity, extends appcompatactivity. fragments swapped in , out needed, , supportfragmentmanager used , have replacefragment() method.

i have following fragments, of either display static information, make rest calls retrieve , display data, or allow user send feedback. extend android.support.v4.app.fragment, , none of them have other fragments or activities user can go to.

  • homefragment
  • calendarfragment
  • standingsfragment
  • playersearchfragment (see below)
  • aboutfragment
  • feedbackfragment

the exception in functionality these fragments playersearchfragment, extends android.support.v4.app.fragment. fragment contains recyclerview displays results of rest call when users want search players. when results returned , user selects item list, sent playerdetailsactivity extends fragmentactivity.

the playerdetailsactivity uses fragmenttabhost view contains different types of information player can viewed. "end of line" down path - there no other fragments or activities user can go to. issue is. when hit button while on activity, intention have user go playersearchfragment fragment (search results), in case, if i'm in nexus 6 emulator, go way navigationmenuactivity activity if i'm on actual nexus 6 device.

i have following method in playerdetailsactivity called when button pressed, shows 0 entries:

@override public void onbackpressed() {      fragmentmanager fragmentmanager = getsupportfragmentmanager();     int count = fragmentmanager.getbackstackentrycount();     log.i(tag, "backstack : there " + count + " entries");     (int = 0; > count; i++) {         fragmentmanager.backstackentry backstackentry = fragmentmanager.getbackstackentryat(i);         log.i(tag, string.format("backstack : id=%d, name=%s, shorttitle=%s, breadcrumbtitle=%s",                 backstackentry.getid(),                 backstackentry.getname(),                 backstackentry.getbreadcrumbshorttitle(),                 backstackentry.getbreadcrumbtitle()));     }      super.onbackpressed(); } 

my hope have experience same devices, whether hardware or emulator.

i think want addtobackstack(fragmentname) called after replace(r.id.frame_menu_container, supportfragment, fragmentname).

tell me happens.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -