Search code examples
android-fragmentsandroid-fragmentactivityarcore

How to add storage permission in ARFragment?


i am using a Custom ARFragment which looks like this

public class CustomARFragment extends ArFragment {
    @Override
    protected Config getSessionConfiguration(Session session) {
        Config config = new Config(session);
        config.setPlaneFindingMode(Config.PlaneFindingMode.HORIZONTAL);
        return config;
    }
}

How can i add storage permission into my project so that whenever the fragment is there it checks for storage permission?


Solution

  • You need to use the fragment's isAdded() method to check whether the fragment is added to the activity. You need to add this condition whenever you want to check for the storage permission. isAdded() returns true if the Fragment is currently added to its activity.

    if(isAdded())
    {
       //check for the storage permission
    }