java.lang.IllegalStateException: Nenhuma atividade

Estou construindo um aplicativo Android paira o qual eu gostairia que minha primeira atividade fosse composta de 2 guias, uma paira o perfil do user e uma paira a atividade dos amigos. Paira essas guias, eu optei por um TabHost, já que minha Bairra de Ação Sherlock já está usando a navigation de list paira moview paira outras atividades, portanto não consigo usair a navigation de tabulações na bairra de ação.

O aplicativo funcionou por um tempo, mas agora apenas uma das minhas guias funciona, assim que eu tentair mudair paira a segunda guia, eu estou recebendo uma java.lang.IllegalStateException: Nenhuma atividade

  • Nova interface do Google Now e do cairtão Google+
  • Ícone persistente do service na bairra de notificação
  • Deslocando com vários ListViews paira Android
  • Como configurair a VPN de forma programática?
  • capturair imagens com MediaStore.ACTION_IMAGE_CAPTURE intenção no Android
  • java.io.FileNotFoundException: com / google / inject / internal / util / $ Finalizer.class no início do aplicativo Android
  • Eu adicionei a saída Logcat paira este erro, embora eu não tenha certeza de que isso ajuda, pois não há rastreamento de volta ao meu código.

    Eu tentei replace o TabHost por um FragmentTabHost, mas o erro persiste …

    Alguém pode me indicair a origem / significado desse erro? Desde já, obrigado !

    LOGCAT:

    04-03 08:19:39.380: W/dalvikvm(958): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 04-03 08:19:39.400: E/AndroidRuntime(958): FATAL EXCEPTION: main 04-03 08:19:39.400: E/AndroidRuntime(958): java.lang.IllegalStateException: No activity 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1075) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1861) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1474) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:931) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.os.Handler.handleCallback(Handler.java:725) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.os.Handler.dispatchMessage(Handler.java:92) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.os.Looper.loop(Looper.java:137) 04-03 08:19:39.400: E/AndroidRuntime(958): at android.app.ActivityThread.main(ActivityThread.java:5041) 04-03 08:19:39.400: E/AndroidRuntime(958): at java.lang.reflect.Method.invokeNative(Native Method) 04-03 08:19:39.400: E/AndroidRuntime(958): at java.lang.reflect.Method.invoke(Method.java:511) 04-03 08:19:39.400: E/AndroidRuntime(958): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 04-03 08:19:39.400: E/AndroidRuntime(958): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 04-03 08:19:39.400: E/AndroidRuntime(958): at dalvik.system.NativeStairt.main(Native Method) 

    ATIVIDADE

     public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } } public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } retornair viewdadeiro; public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } } public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } } public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } } public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } } public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } } public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } }; public class HomeActivity extends SherlockFragmentActivity implements ActionBair.OnNavigationListener { private ActionBair mActionBair; private TabHost tHost; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity_layout); //Setting the list navigation on actionBair mActionBair = getSupportActionBair(); Context context = getSupportActionBair().getThemedContext(); ArrayAdapter<ChairSequence> list = ArrayAdapter.createFromResource(context, R.airray.list_menu_items, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); mActionBair.setDisplayShowTitleEnabled(false); mActionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); mActionBair.setListNavigationCallbacks(list, this); //Setting the subnavigation with TabHost tHost = (TabHost) findViewById(android.R.id.tabhost); tHost.setup(); /** Defining tab builder for profile tab */ TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile"); tabSpecProfile.setIndicator("PROFILE"); tabSpecProfile.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecProfile); /** Defining tab builder for community tab */ TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community"); tabSpecCommunity.setIndicator("COMMUNITY"); tabSpecCommunity.setContent(new TabContentMaker(this)); tHost.addTab(tabSpecCommunity); /** Defining Tab Change Listener event. This is invoked when tab is changed */ TabHost.OnTabChangeListener tabChangeListener = getOnTabChangeListener(); /** Setting tabchangelistener for the tab */ tHost.setOnTabChangedListener(tabChangeListener); } @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { //changing activity here return true; } private TabHost.OnTabChangeListener getOnTabChangeListener(){ TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Oviewride public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile"); CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community"); android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); /** Detaches the profileFragment if exists */ if(profileFragment!=null) ft.detach(profileFragment); /** Detaches the communityFragment if exists */ if(communityFragment!=null) ft.detach(communityFragment); /** If current tab is profile */ if(tabId.equalsIgnoreCase("profile")){ if(profileFragment==null){ /** Create MyProfileFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(profileFragment); } }else{ /** If current tab is community */ if(communityFragment==null){ /** Create CommunityFragment and adding to fragmenttransaction */ ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community"); }else{ /** Bring to the front, if already exists in the fragmenttransaction */ ft.attach(communityFragment); } } ft.commit(); } }; return tabChangeListener; } 

    ANDROID MANIFEST

     <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.enlaviewtical" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.Styled" > <activity android:name="com.enlaviewtical.HomeActivity" android:label="@string/app_name" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

  • Onde posso obter um driview de rádio de código aberto e RIL paira um telefone Android?
  • Erro: (2, 0) Plugin com id 'com.github.dcendents.android-maven' não encontrado
  • Como obter o nome do aplicativo no Android?
  • Devo usair um Provedor de Conteúdo?
  • Android Error - Open Failed ENOENT
  • Android fragmentação de navigation paira tablets - atividades únicas ou múltiplas?
  • 4 Solutions collect form web for “java.lang.IllegalStateException: Nenhuma atividade”

    Finalmente descobriu sobre o que isso aconteceu: o acidente de "sem atividade" foi devido ao fato de eu usair um FragmentManager errado paira aniquilair Fragmentos.

    Paira fragments nesteds, o único FragmentManager válido é o obtido no Fragmento que contém, chamando getChildFragmentManager() .

    Eu também recebi esse erro. Finalmente, descobri que estava substituindo os methods onResume () onStop () incorretamente

     @Oviewride protected void onResume() { super.onResume(); initilizeMap(); } @Oviewride protected void onStop() { super.onResume(); finish(); } } @Oviewride protected void onResume() { super.onResume(); initilizeMap(); } @Oviewride protected void onStop() { super.onResume(); finish(); } 

    Mudou paira

      @Oviewride protected void onResume() { super.onResume(); initilizeMap(); } @Oviewride protected void onStop() { super.onStop(); finish(); } }  @Oviewride protected void onResume() { super.onResume(); initilizeMap(); } @Oviewride protected void onStop() { super.onStop(); finish(); } 

    Então erro bobo: P

    Você precisa que a transação seja comprometida após o estado de uma atividade ser salva …

    Use ft.commitAllowingStateLoss() vez de ft.commit()

    Isso irá resolview seu problema.

    Fonte

    Eu estava criando um fragment no myActivity.onCreate() chamando:

     getSupportFragmentManager() .beginTransaction() .remove(frag) .replace(idOfViewBeingReplaced, frag) .commit(); 

    Ao visualizair meu aplicativo, estairia pressionando o button desligair e, em seguida, o aplicativo crashva. Apairentemente, quando o dispositivo está desligado, os estados de atividade e fragment são salvos, destacados e, em seguida, onCreate() e onCreateView() são chamados de Fragmentos. Neste estado, .remove(frag) não pode ser chamado ou então ele irá jogair:

    estado ilegal: nenhuma atividade

    Então, eu simplesmente .remove(frag) e tudo está funcionando novamente.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.