1

This is my logcat file which shows activity not found exception, even though I have declared it in manifest file.whenever I launch my app in eclipse avd "unfortunately has stopped" warning pops out. please help me with this.

12-15 07:42:47.833: E/AndroidRuntime(770): FATAL EXCEPTION: Thread-75
12-15 07:42:47.833: E/AndroidRuntime(770): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=my.example.myproject.SELECTION }
12-15 07:42:47.833: E/AndroidRuntime(770):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
12-15 07:42:47.833: E/AndroidRuntime(770):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
12-15 07:42:47.833: E/AndroidRuntime(770):  at android.app.Activity.startActivityForResult(Activity.java:3370)
12-15 07:42:47.833: E/AndroidRuntime(770):  at android.app.Activity.startActivityForResult(Activity.java:3331)
12-15 07:42:47.833: E/AndroidRuntime(770):  at android.app.Activity.startActivity(Activity.java:3566)
12-15 07:42:47.833: E/AndroidRuntime(770):  at android.app.Activity.startActivity(Activity.java:3534)
12-15 07:42:47.833: E/AndroidRuntime(770):  at my.example.myproject.FullscreenActivity$3.run(FullscreenActivity.java:72)

Java code and manifest file is as shown below

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fullscreen);
        final View controlsView = findViewById(R.id.fullscreen_content_controls);
        final View contentView = findViewById(R.id.fullscreen_content);
        iol = (Button)findViewById(R.id.iolCalculation);
        help = (Button)findViewById(R.id.sHelp);
        about = (Button)findViewById(R.id.sAbout);
        Thread iolthread=new Thread(){
            public void run(){
                try{
                    iol.setOnClickListener(new View.OnClickListener() {


                            @Override
                            public void onClick(View v) {
                                // TODO Auto-generated method stub
                                setContentView(R.layout.selection);
                            }
                    });
                    Intent iolIntent=new Intent("my.example.myproject.SELECTION");
                    startActivity(iolIntent);
                }
                finally{
                    finish();
                }
            }
        };  
        iolthread.start();

Manifest file

<application
        android:allowBackup="true"
        android:theme="@style/AppTheme">"
        <activity
            android:name=".FullscreenActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Selection"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme" >

                <action android:name="my.example.myproject.SELECTION" />

                <category android:name="android.intent.category.DEFAULT" />

        </activity>
    </application>

I am a beginner in android programming and stack overflow. Bare me if there is any mistake. Below is my main xml file

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    tools:context=".FullscreenActivity" >

    <!--
         The primary full-screen view. This can be replaced with whatever view
         is needed to present your content, e.g. VideoView, SurfaceView,
         TextureView, etc.
    -->

    <TextView
        android:id="@+id/fullscreen_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:keepScreenOn="true"/>

    <!--
         This FrameLayout insets its children based on system windows using
         android:fitsSystemWindows.
    -->

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/Black"
        android:fitsSystemWindows="true" >

        <LinearLayout
            android:id="@+id/fullscreen_content_controls"
            style="?buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:background="@color/black_overlay"
            android:orientation="horizontal"
            tools:ignore="UselessParent" >
        </LinearLayout>

        <Button
            style="@style/ButtonBarButton"
            android:layout_width="222dp"
            android:layout_height="62dp"
            android:layout_marginLeft="45dp"
            android:layout_marginTop="75dp"
            android:background="@color/black"
            android:paddingLeft="20dp"
            android:id="@+id/iolCalculation"
            android:text="@string/Button"
            android:textColor="@color/WhiteSmoke"
            android:textStyle="bold" />

        <Button
            style="@style/ButtonBarButton"
            android:layout_width="222dp"
            android:layout_height="62dp"
            android:layout_marginLeft="45dp"
            android:id="@+id/sHelp"
            android:layout_marginTop="139dp"
            android:background="@color/Black"
            android:gravity="center"
            android:paddingLeft="10dp"
            android:text="@string/Button1"
            android:textColor="@color/WhiteSmoke"
            android:textStyle="bold" />

        <Button
            style="@style/ButtonBarButton"
            android:layout_width="222dp"
            android:layout_height="62dp"
            android:id="@+id/sAbout"
            android:layout_marginLeft="45dp"
            android:layout_marginTop="203dp"
            android:background="@color/Black"
            android:paddingLeft="10dp"
            android:text="@string/Button2"
            android:textColor="@color/WhiteSmoke"
            android:textStyle="bold" >

        </Button>
</FrameLayout>

</FrameLayout>
4

3 回答 3

3

It looks like you forgot to add intent-filter tag to second activity. Try following manifest change

 <activity
        android:name=".Selection"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@style/FullscreenTheme" >
        <intent-filter>
            <action android:name="my.example.myproject.SELECTION" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
于 2012-12-15T08:11:51.153 回答
3

Write below code

Intent mInSelection=new Intent(MainActivity.this,Selection.class);
startActivity(mInSelection);

instead of

Intent iolIntent=new Intent("my.example.myproject.SELECTION");
startActivity(iolIntent);

And write below code into your manifest.xml file

<activity
    android:name=".Selection"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:label="@string/app_name"
    android:theme="@style/FullscreenTheme" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

instead of

<activity
    android:name=".Selection"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:label="@string/app_name"
    android:theme="@style/FullscreenTheme" >

    <action android:name="my.example.myproject.SELECTION" />

    <category android:name="android.intent.category.DEFAULT" />

</activity>

it will solve your problem.

于 2012-12-15T08:12:05.540 回答
1

I know I am late but it can help others. Just add this

Intent mInSelection=new Intent(MainActivity.this,my.example.myproject.SELECTION.class);
startActivity(mInSelection);

it will surely help you.

于 2015-12-07T12:41:40.500 回答