rosjava / android_core

Android libraries for rosjava
145 stars 166 forks source link

It's seems we can't getSupportFragmentManager() from AppCompatRosActivity ?! #304

Open frank0123 opened 5 years ago

frank0123 commented 5 years ago
public class TestActivity extends AppCompatRosActivity implements NodeMain {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...

        // only support getSupportActionBar()
        FragmentManager fm = getSupportFragmentManager();
    }
}
stringnotfound1 commented 5 years ago

You should be able to get the deprecated FragmentManager instead of the one from the support library. This also means that you have to use the deprecated Fragments.

I'm currently doing it this way and haven't gotten any problems so far.

bofetadas commented 4 years ago

I came across the same problem and eventually solved it by not making use of ROSActivity or AppCompatROSActivity anymore. With these Activities, a few disadvantages come along including:

You cannot time the initialization of your nodes. Every time your activity is created/started/resumed 'init' function is called. This is especially bad if you may have service clients which are dependent on their service servers. Due to the fact that rosjava does not offer any 'wait_forservice functionality as the python implementation does, initialization of service clients will fail if their service server isn't up and running yet.

Another issue is that AppCompatROSActivity is pretty old and therefore - as you indicated - doesn't make use of the new supportFragmentManager.

If you want to learn how to get rid of using ROSActivity, have a look here:

rosjava without ROS activity