android-fragmentactivity

How to properly retain a DialogFragment through rotation?

只谈情不闲聊 提交于 2019-11-28 03:14:44
I have a FragmentActivity that hosts a DialogFragment. The DialogFragment perform network requests and handles Facebook authentication, so I need to retain it during rotation. I've read all the other questions relating to this issue, but none of them have actually solved the problem. I'm using putFragment and getFragment to save the Fragment instance and get it again during activity re-creation. However, I'm always getting a null pointer exception on the call to getFragment in onRestoreInstanceState. I would also like to keep the dialog from being dismissed during rotation, but so far I can't

Jar-file issue with ADT r17

丶灬走出姿态 提交于 2019-11-28 00:06:50
问题 I seem to have a tricky problem since the latest ADT update to release 17. I have made a simple application to illustrate my problem, I don't know if I'm doing anything wrong. The main Activity of my application is inheriting from FragmentActivity in the support package and somehow the application crashes at launch. To illustrate, I made a sample project. First of all, here is the code of my dummy class, DummyProjectActivity, very simple: public class DummyProjectActivity extends

Bind service to FragmentActivity or Fragment?

允我心安 提交于 2019-11-27 20:16:43
Is it better to bind service to FragmentActivity : bindService(Intent, ServiceConnection, int); or to Fragment : getActivity().bindService(Intent, ServiceConnection, int); What is better practice? Is it better to bind service to FragmentActivity... or to Fragment They are the same as you have them written here. getActivity() is not a Fragment -- it is a method that returns the Activity . You cannot call bindService() on a Fragment . What is better practice? Neither. Bind to the Application object, obtained via getApplicationContext() , with the ServiceConnection managed by (or perhaps actually

Hide/Show Action Bar Option Menu Item for different fragments

随声附和 提交于 2019-11-27 17:41:20
I have a Sherlock Fragment Activity in which there are 3 Fragments. Fragment A, Fragment B, Fragment C are three fragments. I want to show a done option menu in Fragment B only. And the activity is started with Fragment A. When Fragment B is selected done button is added. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if(!menusInflated){ inflater.inflate(R.menu.security, menu); menusInflated=true; } super.onCreateOptionsMenu(menu, inflater);

getSupportActionBar using FragmentActivity

喜夏-厌秋 提交于 2019-11-27 17:25:53
问题 I'm using fragment activity on one project, but it seems v4 support FragmentActivity doesn't has getSupportActionBar() method, and I need to use the support one in order to use android.support.v7.app.ActionBar 回答1: The ActionBarActivity does support the method you require, and is a subclass of FragmentActivity . See: http://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html 回答2: to use getSupportActionBar() you need extends ActionBarActivity like this http:/

Bring Fragment to Front (No fragment recreation)

情到浓时终转凉″ 提交于 2019-11-27 15:42:07
问题 I have three fragments F1 F2 F3 F4 all are accessible from sidebar. all four can be called at any time and in any order, Now I want if, F1 is already clicked(created) then never again create F1, but only bring back fragment F1 to front using fragment manager. Same for all other fragment So far i tried this for every fragment in my container (FRAGMENT ACTIVITY) if (fragmentManager.findFragmentByTag("apps")==null) { FragmentManager fragmentManager = getSupportFragmentManager();

Pass data between two fragments without using activity

大兔子大兔子 提交于 2019-11-27 14:32:33
I want to pass data between two fragments without using activity and fragment activity. I don't want to pass data between fragments using activity like this : Communicating with Other Fragments Below is my scenario : I have one Parent fragment and inside that there are two child fragments.Now my need is to pass data between these two fragments.How to achieve this? I looked into this : Event Bus but not getting working example for fragments. Is there any other alternative to pass data between fragments? Any help will be appreciated. Edited as per InnocentKiller's answer : In FragmentOne , I

Android Navigation Drawer Fragment State

心已入冬 提交于 2019-11-27 14:04:19
问题 I'm currently utilizing the Navigation Drawer for my Android APP. In my first fragment, I've a fragment that loads data using Facebook's Graph API. Thus, when my App is first loaded, it first goes to the first fragment. Then, I use the Navigation Drawer to click on another Fragment and view it. And then finally, I reuse the Navigation Drawer to proceed back to the first Fragment and view it. My issue that I'm facing is, how do I proceed to utilize the Fragment that has been created once

Android check null or empty string in Android

戏子无情 提交于 2019-11-27 11:52:08
问题 In my trying AsyncTask I get email address from my server. In onPostExecute() I have to check is email address empty or null . I used following code to check it: if (userEmail != null && !userEmail.isEmpty()) { Toast.makeText(getActivity(), userEmail, Toast.LENGTH_LONG).show(); UserEmailLabel.setText(userEmail); } But in my Toast I see null is printed. My full code: private class LoadPersonalData extends AsyncTask<String, Void, Void> { @Override protected void onPreExecute() { super

Manage toolbar's navigation and back button from fragment in android

血红的双手。 提交于 2019-11-27 11:40:48
All of my fragments are controlled through ActionBarActivity (mainActivity), inside mainActivity a DrawerLayout is implemented and all the child fragments are pushed through drawerLayout's list item click. The problem that I'm facing is after pushing a fragment through drawerLayout I want to change the drawer icon into back icon of ToolBar so that user can navigate to previous fragment and to handle the callback of android.R.id.home either inside the same fragment or inside the mainActivity. The code that I am using is: MainActivity.java public class MainActivity extends ActionBarActivity {