Reputation: 2681
I have different activities in different packages,
Suppose I have two package ->com.pack1 ->com.pack2
I have a Activity in pack1 and want to call another Activity in pack2. How will I do that, using intents shows
21:19:10.405: W/System.err(7578): android.content.ActivityNotFoundException: Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml?
Upvotes: 0
Views: 1718
Reputation: 95578
Normally activities are private to their package. You can't start an activity in another package unless that activity is explicitly "exported" (ie: made known to other applications). Add this to you manifest for FlipAgain2Activity in com.pack2:
android:exported="true"
Upvotes: 1
Reputation: 6263
OK, so there are two parts that work together to define the Activity
location. First, is the package
attribute-- below it is `"com.flipagain2"
Also there is the android:name
attribute, which, for example, is .FlipAgain2Activity.
So, this means when Android looks for your activity, it is looking at
com.flipagain2.FlipAgain2Activity.
Make sense? Just combine those two things.
So, you want Activities in two packages.
Change the second (one that isn't working" to look like this:
<activity android:name="com.package2.CaptureActivity" >
<intent-filter>
<action android:name="com.google.zxing.client.android.CaptureActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Do you see what I changed? Leave the first Activity
declaration the same, but change the second android:name=
to match the fully qualified name including the package. Using this approach, every Activity can be in a different package.
Upvotes: 1
Reputation: 2029
Intent i = new Intent("android.intent.action.MAIN");
i.setComponent(new ComponentName("com.mypkg.mystff","com.mypkg.mystuff.MyClass"));
The other answers are correct as well. This, however, will work from anywhere in the device.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Add this to the part of your xml
Upvotes: 2
Reputation: 9284
You need to make sure you declare the activity in you AndroidManifest.xml or you can't use it.
Example:
<activity
android:name="com.yourpackage.YourActivity"
android:launchMode="singleTop"
android:configChanges="orientation"
>
</activity>
Upvotes: 1
Reputation: 6201
Please read the error.
"Have you declared this activity in your AndroidManifest.xml". pakage do not make problem For go one Activity another Activity. Check you AndroidManifest.xml that activity are declear in AndroidManifest.
I think problem happen for this reason.
thanks.
Upvotes: 1