3

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

cliff2310
  • 570
  • 2
  • 15
  • 28
  • I also tried Intent i = new Intent (this, BookView.class); and I get "02-04 14:24:31.750: E/AndroidRuntime(480): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.crl.mybooks/net.crl.mybooks.BookView}: java.lang.NullPointerException" – cliff2310 Feb 04 '12 at 20:27

6 Answers6

6

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

cliff2310
  • 570
  • 2
  • 15
  • 28
4

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>
CChi
  • 3,054
  • 1
  • 20
  • 15
  • I tried that. I get the same result, or one that has 'new.xxx.MyBooks/net.xxx...' But thanks for the reply. Cliff – cliff2310 Feb 04 '12 at 18:21
1

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.

林果皞
  • 7,539
  • 3
  • 55
  • 70
0

I got this problem after I renamed some activities. Make sure you update your AndroidManifest to reflect renaming changes.

Rowan Freeman
  • 15,724
  • 11
  • 69
  • 100
0

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

Phuong
  • 1,251
  • 1
  • 10
  • 6
0

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.

Vikram Rao
  • 514
  • 3
  • 16