ActivityScreens
ActivityScreens copied to clipboard
Open method with Fragment parameter support
Is it possible to add a support to start Activity from a Fragment? According to the following documentation.
Actually, sometimes, it can be useful to start an Activity (and occasionally for result) from a Fragment.
So we will obtain something like this:
// Fragment section
public void open(android.app.Fragment fragment) {
Intent intent = toIntent(fragment);
fragment.startActivity(intent);
}
public void openForResult(android.app.Fragment fragment, int requestCode) {
Intent intent = toIntent(fragment);
fragment.startActivityForResult(intent, requestCode);
}
// Support fragment section
public void open(android.support.v4.app.Fragment fragment) {
Intent intent = toIntent(fragment);
fragment.startActivity(intent);
}
public void openForResult(android.support.v4.app.Fragment fragment, int requestCode) {
Intent intent = toIntent(fragment);
fragment.startActivityForResult(intent, requestCode);
}
Makes sense. Also will be good with IntentBuilder
suggested in #3.