views:

325

answers:

3

Hi All.. I am getting this exception while I am trying to call an activity from another one.. .The complete exception is android.content.ActivityNotFoundException:Unable to find explicit activity class {com.x.y/com.x.y.class};

I am doing an intent.setClass("com.x.y","com.x.y.className") where className is the name of my activity class and com.x.y is the package it resides in.

My AndroidManifest.xml has the following content:

Am I missing anything ??

Thanks in advance..

+1  A: 

intent.setClass takes parameters as "Package Context" and "Class". an example would be:

intent.setClass(CurrentActivity.this, TargetActivity.class);

also you need to check if the activity is registered in manifesto file.

Andy Lin
A: 

Looking at the documentation here what you want is:

intent.setClassName("com.x.y", "className");
sir.jamesgreen
Thank u for the quick answer :) .. But I am using the following method "setClassName(String packageName, String className)" of the Intent class.. And my manifest file contains the following entry :<activity android:name="com.x.y.className" android:label="@string/app_name"> </activity>Should I add any intent filters ? I am creating my Intent with the following code : Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("com.x.y", className.class.getName()); activity.startActivity(intent);
paypalcomp
I believe you will need to add <intent-filter> <action android:name="android.intent.action.VIEW" /></intent-filter>Between your activity tags in the manifest file.
sir.jamesgreen
Nope.. Still no luck.. Get this error :android.content.ActivityNotFoundException: Unable to find explicit activity class {com.x.y/com.x.y.className}; have you declared this activity in your AndroidManifest.xml?Added the following in my Manifest file :<activity android:name="com.x.y.className" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.VIEW" /> </intent-filter> </activity>:(
paypalcomp
Anyways.. did Intent intent = new Intent(activity,CartActivity.class); activity.startActivity(intent);and it worked like a charm :)Thank you soo much
paypalcomp
A: 

Maybe you need to check that you added the new activity to the manifest.xml file

Mina Samy
I already have the following entry :<activity android:name="com.x.y.className" android:label="@string/app_name"> </activity>Still no luck :(
paypalcomp