Reputation: 590
I am trying to start an activity from my main activity. Its not working and driving me nuts. What I have is:
Intent i = new Intent ("net.xxx.View1");
Context con = this.getBaseContext();
ComponentName cn = new ComponentName("net.xxx.Mybooks", "BookView");
i.setComponent(cn);
Bundle extras = new Bundle();
ooo
i.putExtras(extras);
startActivity(i);
Manifest is:
android:name="BookView" >
<intent-filter >
<action android:name ="android.intent.action.VIEW" />
<action android:name ="net.xxx.View1" />
<category android:name ="android.intent.category.DEFAULT" />
</intent-filter>
What I get is:
*02-03 19:34:47.448: E/AndroidRuntime(2027): android.content.ActivityNotFoundException: Unable to find explicit activity class {net.xxx.Mybooks/BookView}; have you declared this activity in your AndroidManifest.xml *
Which would be correct, I think, if the '/' was a '.'
I tried with context and without any componetName, the result is always the same.
SdkVersion="10"
Thanks in advance for your help
Cliff
Upvotes: 3
Views: 10192
Reputation: 7793
I have similar problem after refactor my package name, and I finally found that my applicationId
value in build.gradle
has typo, and Android Studio doesn't give any warning.
Upvotes: 1
Reputation: 514
Make sure your activity is defined in manifest. I had copy pasted a Activity class and forgotten to add the definition in manifest file and ended up with this problem.
Upvotes: 0
Reputation: 1251
I also get this when I put Activity-derived class nested in another class, so it can not be found, moving outside solves the problem
Upvotes: 0
Reputation: 16348
I got this problem after I renamed some activities. Make sure you update your AndroidManifest to reflect renaming changes.
Upvotes: 0
Reputation: 590
Well despite the clams of activity not found, the problem was in the new activity. It had a null pointer exception in the code. So I spent a day or so chasing the wrong problem.
Thanks for your time anyway
Cliff
Upvotes: 6
Reputation: 3134
Try putting a "." in front of BookView Try doing something like this in your manifest.
<activity android:name=".BookView" >
<intent-filter >
<action android:name ="android.intent.action.VIEW" />
<action android:name ="net.xxx.View1" />
<category android:name ="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Upvotes: 4