android-fragments - 从 FileObserver 服务启动片段
问题描述
我需要从 FileObserver 服务打开一个片段。我尝试这样,但它不起作用
MyFragment newFragmentTop = new MyFragment();
getActivity().getSupportFragmentManager().beginTransaction()
.add(R.id.container, newFragmentTop, "newFragmentTop")
.addToBackStack(null)
.commitAllowingStateLoss();
我也尝试获取 getApplicationContext() 但我无法从中获取 getSupportFragmentManager() 。如何在不启动活动的情况下打开片段?
解决方案
推荐阅读
- php - Yii2 Invalid Configuration, cookieValidationKey 访问API时必须配置秘钥错误
- r - 如何创建一个向上计数的数据框
- gremlin - Gremlin - Select vertices based on group keys
- html - 有条件的中心元素
- python - Digital Ocean nginx/启用站点的问题
- git - 从 GIT 存储库 (Jenkins/GIT) 构建一个项目
- java - 面试编程问题?(长位表示)?
- php - 如何为 HTML 表单输入设置默认值?
- c# - 为什么即使功能正常工作,测试也不能正确评估?
- angular - Angular 9 警告 typescript.js