简体   繁体   中英

Android: No Activity found to handle Intent error?

Im getting the error in the title when just messing around with android programming:

Code :

package co.uk.mypchealth.whatami;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Thread logoTimer = new Thread(){
            public void run(){
                try {
                       sleep(3000);
                       Intent menuIntent = new Intent("co.uk.mypchealth.whatami.JAVAMENU");
                       startActivity(menuIntent);
                } 
                catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                finally{
                    finish();
                }
            }
        };
        logoTimer.start();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }
}

and the manifest :

  <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="co.uk.mypchealth.whatami"
        android:versionCode="1"
        android:versionName="1.0" >

        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />

        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="co.uk.mypchealth.whatami.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>

            <activity
                android:name=".JavaMenu"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="co.uk.mypchealth.whatami.JAVAMENU" />
                    <category android:name="android.intent.category.DEFUALT" />
                </intent-filter>
            </activity>

        </application>

</manifest>

Im Hoping its something simple i mean jeeze the app does nothing yet lol.... i have the intent declared and and all the names i have checked and double checked ... just cant see the wood from the trees. Any help would be great.

Try,

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

    @Override
    public void run() {
     Intent menuIntent = new Intent(MainActivity.this, JavaMenu.class);
     startActivity(menuIntent);
        }
        }, 3000);

try this :

        <activity
            android:name=".JavaMenu"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="co.uk.mypchealth.whatami.JAVAMENU" />
                <category android:name="android.intent.category.DEFUALT" />
            </intent-filter>
        </activity>

you have defined the app name in both activities try to change this activity declaration to :

 <activity   android:name="co.uk.mypchealth.whatami.JavaMenu" >    </activity>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM