Reputation: 329
I'm using a third-party application that just launches a class that extends another normal class. So, from that class I would like to launch an activity:
public class SkyTest extends VtiUserExit {
@Override
public VtiUserExitResult execute() throws VtiExitException {
// TODO Auto-generated method stub
logInfo("TEST");
return null;
}
}
How do I launch an activity named MainActivity
from here?
I tried this:
Context context = null;
Intent intent = new Intent(context, MainActivity.class);
context.startActivity(intent);
but it's not working. I know I can't use the null context, but how do I create a context so it works?
Upvotes: 1
Views: 134
Reputation: 7416
A null
context doesn't work because Android needs that Application Context in order to find your Activity. I don't know which framework you are using, but you should look for a way to grab a reference to the Context, have you gone through the API for the class you're extending?
Upvotes: 2