user3401222
user3401222

Reputation: 3

Android Intent problems

I'm having an issue trying to go to a specific class within my android application using the Intent.

This is my code setup:

Intent Secondscreenintent = new Intent(this, Secondscreen.class);

The error that it gives me is

android.content.ActivityNotFoundException: Unable to find explicit activity class {/project10.aventus.quiz.Secondscreen}; have you declared this activity in your AndroidManifest.xml?

After looking at my manifest I could not see any mistakes that would indicate this message.

<activity
    android:name=".Main"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:label="Quiz">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity
    android:name=".Secondscreen"
    android:label="Secondscreen" />
<activity
android:name=".Quizclass"
android:label="Quizclass"/>

These are within the tag within the tag.

But somehow I'm still getting the class not found error. I have even tried to refer the intent to the Main.class and this has given the same error that it cannot find the Main class.

Does anyone have an idea on how to fix this?

Thanks, Shams.

Upvotes: 0

Views: 79

Answers (1)

devops
devops

Reputation: 9179

In you AndroidManifest.xml you will find some thing like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="project10.aventus.quiz"
   android:versionCode="1"
   android:versionName="your_version_code">
   ...
</manifest>

package defines the root of your implementation. So you don't have to write the full path name if you define Activities, BroadCastReceiver etc...

So you do it in this way:

<activity
    android:name=".Secondscreen"
    android:label="Secondscreen" />

This entry means - you will find my Secondscreen.java in my root folder aka package. In your case it would be project10.aventus.quiz.

So i quess your Secondscreen.java is not there. I'm creating allways a new subpackage ui in my root folder, so my activity entry looks like this:

 <activity
       android:name=".ui.Secondscreen"
       android:label="@string/second_screen"
       android:screenOrientation="portrait" >
 </activity>

Now, this entry means - you will find my Secondscreen.java here: project10.aventus.quiz.ui.Secondscreen.java

Upvotes: 1

Related Questions