Skip to content

Activity Intent builder

Roman Tcaregorodtcev edited this page Apr 2, 2018 · 5 revisions

Create intent to start new activity. Just add activity class name to constructor and start activity.

OmegaIntentBuilder.from(this)
                .activity(PhotoCaptureActivity.class)
                .startActivity();

Also you can put data to extras.

OmegaIntentBuilder.from(this)
                .activity(PhotoCaptureActivity.class)
                .putExtra("Your_key", Integer.MAX_VALUE)
                .putExtra("Your_key2", Integer.MIN_VALUE)
                .startActivity();

If you want to catch exception when startActivity called, just add method "createIntentHandler".

        OmegaIntentBuilder.from(this)
                .activity(PhotoCaptureActivity.class)
                .putExtra("Your_key", Integer.MAX_VALUE)
                .putExtra("Your_key2", Integer.MIN_VALUE)
                .createIntentHandler()
                .failCallback(new FailCallback() {
                    @Override
                    public void onActivityStartError(@NotNull Exception exc) {
                        // you can handle error here
                    }
                })
                .failToast("Error")
                .startActivity();

Clone this wiki locally