Chris Muench
Chris Muench

Reputation: 18318

startActivity using android:name

Manifest definition:

 <activity android:name="com.gannett.democratandchronicle.billstrainingcamp.PlayersActivity" />

WORKS:

startActivity(new Intent(this, PlayersActivity.class));

DOESN'T WORK: (No activity found)

startActivity(new Intent("com.gannett.democratandchronicle.billstrainingcamp.PlayersActivity"));

Why can't I use the full android:name to startActivity? Is the string parameter expecting something different?

Upvotes: 1

Views: 66

Answers (1)

iagreen
iagreen

Reputation: 31996

It is an action, not a name. If you want to be able to launch your activity that way, add

<intent-filter>
     <action android:name="com.gannett.democratandchronicle.billstrainingcamp.PlayersActivity" />
</intent-filter>

to your activity, or you can use any name you want for the action, it does not have to be the name of the class. It does, however, have to have a namespace.

Upvotes: 1

Related Questions