Suppose I have two Activity(under the same package):
HomeActivity(The launcher activity)
SpinnerActivity
Both of them are registered at the AndroidManifest.xml
.
Now I try to create a method to implement the activity jump:
private void redirectToActivity(String dest) {
Intent intent = new Intent();
intent.setClassName(this,dest);
startActivity(intent);
}
And I call it in the HomeActivity
:
redirectToActivity("SpinnerActivity");
But I got this error:
Unable to find explicit activity class {com.app/SpinnerActivity}; have you declared this activity in your AndroidManifest.xml?
I tried to add this line:
intent.setPackage("com.app");
It does not work.
What's the problem?