import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
public class MainActivity extends Activity {
FragmentManager fm;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fm = getFragmentManager();
log("onCreate()");
}
I'm trying to create two fragments that communicate with the main activity, but the moment I insert getFragmentManager, the IDE gives me an error in which it says that I imported an incorrect class, when in reality the right class is already present. How can I solve it?
(fm = getFragmentManager(); is deprecated and an error in my code)
Update: i've changed getFragmentManager() with getSupportFragmentManager() but Nothing!!!