android.content.ActivityNotFoundException很多

时间:2011-12-16 10:32:30

标签: android android-activity

我没有得到以下错误修复(logcat):

E/AndroidRuntime( 1010): FATAL EXCEPTION: Thread-105
E/AndroidRuntime( 1010): android.content.ActivityNotFoundException: No Activity
found to handle Intent { act=com.androidpeople.xml.parsing.appz }
E/AndroidRuntime( 1010):        at android.app.Instrumentation.checkStartActivit
yResult(Instrumentation.java:1512)
E/AndroidRuntime( 1010):        at android.app.Instrumentation.execStartActivity
(Instrumentation.java:1384)
E/AndroidRuntime( 1010):        at android.app.Activity.startActivityForResult(A
ctivity.java:3190)
E/AndroidRuntime( 1010):        at android.app.Activity.startActivity(Activity.j
ava:3297)
E/AndroidRuntime( 1010):        at com.androidpeople.xml.parsing.Splash$1.run(Sp
lash.java:30)

尝试了很多,但也许有人看到了光。;)

Splash.java。任何类都没有编译错误。只有在模拟器上,应用程序才会在启动画面后崩溃

package com.androidpeople.xml.parsing;

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

public class Splash extends Activity {
    protected boolean _active = true;
    protected int _splashTime = 2000;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);

        Thread splash = new Thread(){
            @Override
            public void run(){
                try{
                    int waited= 0;
                    while(_active && (waited < _splashTime)){
                        sleep(100);
                        if(_active){
                            waited += 100;
                        }
                    }
                }catch(InterruptedException e){
                }finally {
                    finish();
                    startActivity(new Intent(Splash.this , appz.class));
                    stop();
                }
            }
        };
    splash.start();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event){
        if(event.getAction() == MotionEvent.ACTION_DOWN){
            _active = false;
        }
        return true;
    }
}
de appz.java是:

package com.androidpeople.xml.parsing;

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

public class appz extends Activity{
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.example);
    }

}

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.androidpeople.xml.parsing"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Splash">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       <activity
            android:label="Appz"
            android:name=".appz" />      
    </application>


<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>

随着这个atm获得屏幕,但即时崩溃

4 个答案:

答案 0 :(得分:2)

检查您是否在清单文件中的活动标记中声明了活动。

编辑:

清单文件:

...
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        ...
        <activity
            android:label="Appz"
            android:name=".Appz" />            
    </application>
...

答案 1 :(得分:1)

我确信您已经从Androidpeople.com网站下载了XML解析教程,是的,为了解决上述问题,只需检查AndroidManifest.xml文件,无论您是否已声明活动。

 <activity
     android:label="@string/app_name"
     android:name=".appz">
      <intent-filter >
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
 </activity>

当您尝试实施Splash屏幕活动时,这应该是MAIN和LAUNCHER,因此对此活动应用intent-filter。

仅供参考,每当您在应用程序中声明任何活动并使用相同的活动时,都必须在AndroidManifest.xml文件中声明。

答案 2 :(得分:0)

你的班级appz应该延伸Activity - 我认为它会这样做。

最有可能的问题是,您没有按照here的说明将其添加到AndroidManifest.xml

  

启动特定活动的能力可以在其清单标签中声明时强制执行。

答案 3 :(得分:0)

在调用新意图之前调用了finish方法          所以它缺少上下文请使用此代码  我已经改变了订单

     Thread splash = new Thread(){
        @Override
        public void run(){
            try{
                int waited= 0;
                while(_active && (waited < _splashTime)){
                    sleep(100);
                    if(_active){
                        waited += 100;
                    }
                }
            }catch(InterruptedException e){
            }finally {
                runOnUiThread(new Runnable(){
                startActivity(new Intent(Splash.this , appz.class));
               }
             this.finish();
            }
        }
    };
splash.start();