Genadinik
Genadinik

Reputation: 18639

android - how to switch screens with an intent if the original class is not an Activity?

Usually if I want to switch screens, I do something like this:

Intent myIntent = new Intent(CurrActivity.this, NextActivity.class);
CurrActivity.this.startActivity(myIntent);

but I am in a situation where I would like to do this from a regular class. Actually it is an abstract class. It is named PurchaseObserver and its part of the Android billing setup.

Is it possible to do a change of screens from this class? Something similar to the intent code I posted above?

Thanks!

Upvotes: 0

Views: 79

Answers (1)

bennettaur
bennettaur

Reputation: 1253

When you instantiate the class, pass a Context in the constructor and use that to start an Activity using startActivity(Intent)

Upvotes: 2

Related Questions