'Square up FLOW navigation
I followed Lukaspili Demo to create MVP architecture project for Motor & Flow framework integration. I want to have two different activities with for before login & after login. I am not able to get parent activity instance to create the new Intent(ParentActivity.this, NewActivity.class). Is any one faced this situation?
Solution 1:[1]
You should be able to obtain the Activity as the base context
of your view.
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 + "]");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | EpicPandaForce |