Tag: android-fragments

Android: onActivityResult in fragment not called

Found numerous post regarding my issue but none of them worked out for me. I have a fragment from where I have to call startActivityForResult() on a textview click. From there, an activity will open up where user will fill some data and submit it to database. From there, I have to pass an intent […]

How to use Dialog Fragment? (showDialog deprecated) Android

I understand that there is this documentation http://developer.android.com/reference/android/app/DialogFragment.html#AlertDialog but as a new Android/Java learner it is not easy to understand the amount of code involved from writing a simple alert dialog that pops up with 2 options (yes/no) message. Here is the code I currently have in my MainActivity file: final private int RESET_DIALOG = […]

Call startActivityForResult from Fragment doesn't call onActivityResult

I have a DialogActivity which is called from a Fragment for show a custom Dialog with two image buttons. In DialogActivity.onCreate final Dialog dialog = new Dialog(this, R.style.DialogTheme); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_pause); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.show(); In DialogActivity.onClick @Override public void onClick(View v) { Log.d(LOGTAG, “onClick CONTINUE”); Intent resultData = new Intent(); resultData.putExtra(“TEST”, “return data”); setResult(666, resultData); dialog.cancel(); […]

Viewpager in fragment is not shown(restored) when go back from other fragment

I’m facing the problem as following: In main screen, I have 3 buttons: Config, Main, Setting. When each button is clicked, a corresponding fragment will be shown to inflate layout in a FrameLayout. When user is in Config or Setting Fragment, it is able to go back to main Fragment using onBackpressed or click on […]

Should I use AppCompat v7 if minsdk is 14

should I still use app compat v7 if my app has minSdk = 14? Is there any advantage with ActionBar in Android L ? Should I use android.support.v4.app.FragmentActivity from support v4 or should I use the android.app.Activity class (which has support for fragments since honeycomb)? Should I also use android.app.Fragment or android.support.v4.app.Fragment? I guess that […]

IllegalStateException: Fragment <ThisFragment> is not currently in the FragmentManager

I have trouble of tracing the cause of the crash in my app. I have a fragment that displays a ListView, I also have SlidingMenu for a search field. And when I search, the ListView items are repopulated basing from the search results. Now, my app crashes when I try to open a ListView item […]

Android replace fragment still displays some of the replaced fragment

I have a tab that contains a linear layout with a searchview and a listview. When the user clicks one of the search results, I want to replace that layout with another layout containing the details of the selection. What happens when I replace the search fragment only the listview portion of the layout gets […]

Refresh fragment when dialogfragment is dismissed

Is there any way I can detect when a DialogFragment is dismissed, so that i can update its parent fragment?

Android – Unable to destroy activity after finish, caused by IllegalStateException: Can not perform this action after onSaveInstanceState

I have an activity in my app with 3 fragments. When a button is pushed on the first one, a method is called in the Activity that does some irrelevant stuff and then calls finish(). This triggers onPause() on the fragment, which does more irrelevant stuff and then calls super.onPause(). The app then loads the […]

Android onBackStackChanged() not called

I have an Activity like the code below: public class AuthenticatedMainActivity extends Activity implements FragmentManager.OnBackStackChangedListener{ @Override protected void onCreate(Bundle savedInstanceState) { …………. FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().add(R.id.frame_container,fragment, “First”).addToBackStack(null).commit(); } private void switchFragment(Fragment fragment){ FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).addToBackStack(“Tag”).commit(); } @Override public void onBackStackChanged() { System.out.println(“====================================================changeeeeeeeeeeeeeeeeeeeeeeeeee”); } } But the onBackStackChanged() method is never […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.