Cannot Resolve Method 'Getsupportfragmentmanager ( )' Inside Fragment

Cannot resolve method 'getSupportFragmentManager ( )' inside Fragment

Inside a Fragment subclass you have to use getFragmentManager in place of getSupportFragmentManager. You will get the support one if the import are from the support library.

Can not resolve method getSupportFragmentManager()

getSupportFragmentManager is method of FragmentActivity,not TabActivity,so you just replace it with getFragmentManager().

Cannot resolve Method getSupportFragmentManager() or ((FragmentActivity)activity)getSupportFragmentManager()

You need an Activity to host that Fragment. A Fragment cannot be possible without a hosting Activity. At first, create an Activity (eg. AlarmActivity) with transparent background (You can achieve with themes) which has a FragmentContainerView to host your fragment. When you receive broadcast in your BroadcastReceiver, start this activity:

Intent intent = new Intent(context, AlarmActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // This is required
context.startActivity(intent);

Cannot resolve method super() error in fragmentmanager Android

Using the super() in a constructor you are trying to call the constructor of the parent class.

In this case the FragmentStateAdapter has 3 constructors:

FragmentStateAdapter(FragmentActivity fragmentActivity)
FragmentStateAdapter(Fragment fragment)
FragmentStateAdapter(FragmentManager fragmentManager, Lifecycle lifecycle)

In your case you have:

public AuthenticationPagerAdapter(FragmentManager fragmentActivity)

and super(FragmentManager); doesn't match any super constructor.

You can use something like:

public AuthenticationPagerAdapter(FragmentActivity fragmentActivity) {
super(fragmentActivity);
}

public AuthenticationPagerAdapter(FragmentManager fragmentManager,Lifecycle lifecycle) {
super(fragmentManager, lifecycle);
}

Android Fragment cannot resolve add method

@Courtesy To Md

Use import android.support.v4.app.Fragment instead import android.app.Fragment

android.support.v4.app.Fragment is the Fragment class in the android support library, which is a compatibility package that allows you to use some of the newer features of Android on older versions of Android.Reference

Please add this in your gradle dependencies

compile 'com.android.support:support-v4:22.1.1'


Related Topics



Leave a reply



Submit