As an alternate to Dalmas' answer, you can actually export an Activity
without creating an <intent-filter>
(along with the hassle of coming up with a custom action).
In the Manifest
edit your Activity
tag like so:
<activity
android:name=".SomeActivity"
....
android:exported="true" />
The important part is android:exported="true"
, this export
tag determines "whether or not the activity can be launched by components of other applications". If your <activity>
contains an <intent-filter>
then this tag is set to true
automatically, if it does not then it is set to false
by default.
Then to launch the Activity
do this:
Intent i = new Intent();
i.setComponent(new ComponentName("package name", "fully-qualified name of activity"));
startActivity(i);
Of course with this method you will need to know the exact name of the Activity you are trying to launch.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…