我跟着Lukaspili Demo为电机创建MVP架构项目&流程框架集成。我想在登录后登录&之前进行两项不同的活动。我无法获取父活动实例来创建新的Intent(ParentActivity.this,NewActivity.class)。有没有人遇到这种情况?Square up FLOW navigation
回答
您应该能够获得您的视图的base context
活动。
public static Activity getActivity(Context context) {
if(context instanceof Activity) {
return (Activity) context;
} else if(context instanceof ContextWrapper) {
Context baseContext = ((ContextWrapper) context).getBaseContext();
if(baseContext instanceof Activity) {
return (Activity) baseContext;
}
}
Log.e(TAG, "No activity could be found in [" + context + "]");
throw new IllegalStateException("No activity could be found in [" + context + "]");
}
演示者只保存视图上下文。因此我们不能通过上述方法获得活动上下文。我们需要通过Dagger作用域实现..但是,我正在努力获得它 – Jeyahariprakash
您应该能够使用此方法从View上下文中提取Activity上下文。请尝试。但是,如果基本上下文是**不是**一个活动,那么我会尝试找出一些东西。此方法在Flow 1.0.0-alpha中不起作用。 – EpicPandaForce
我只使用Flow 0.12。我收到错误消息“无法在[[email protected]]中找到活动”。 – Jeyahariprakash
- 1. Square Flow + Mortar平板电脑示例
- 2. Square Up API Edge浏览器问题
- 3. 如何在Android Studio中引用android navigation up图标?
- 4. Jquery scroll up up
- 5. Javascript Events up up
- 6. Square ImageView
- 7. jquery navigation
- 8. Zend2 navigation
- 9. spinner did nott up up
- 10. android:alarm not wake up up
- 11. Label is not up up
- 12. matlab input-output:convert square inches to square cm?
- 13. Java boolean if-statement up up
- 14. Autowire on new-up up object
- 15. notfiy-send not up up with upstart
- 16. Google Website Translator up up HTML
- 17. Java Square函数
- 18. FloatingActionButton Shadow by Square
- 19. square Facebook图片
- 20. Sorting a Square Matrix
- 21. Square Grid - XML
- 22. Android - Square TableLayout
- 23. Python Perfect Square
- 24. Javascript Square Multi Array
- 25. Responsive CSS square
- 26. android activity stack-back navigation
- 27. iOS App navigation
- 28. CSS dropdown navigation
- 29. Tableview with Navigation bar
- 30. Second Navigation Bar
哪个版本的Flow? 1.0.0-alpha或0.12? – EpicPandaForce
哦,它是流量0.10。这是一段时间以前...让我想出来 – EpicPandaForce
@EpicPandaForce:它的流0.12 – Jeyahariprakash