我无法将splash传递给另一个活动

时间:2014-02-23 18:56:30

标签: android xml android-intent splash

我的程序有splassh页面我曾经意图将splash活动传递给我的主活动文件夹但是当我运行我的程序时它会在我的启动后停止 这是我的泼水课和manıfestxml和我的logcat

package com.tesbih;

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

public class Splash extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
         // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(R.layout.splash);
        Thread timer = new Thread(){

             public void run(){
                 try{
                    sleep(5000);
                }catch(InterruptedException e){

                    e .printStackTrace();

                }finally{

   Intent openStartingPoint = new Intent ("com.tesbih.TESBIHMAINACTIVITY");
   startActivity(openStartingPoint);

                }
            }   
        };

        timer.start();
    }
  }

并遵循我的清单

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

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

  <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.tesbih.TesbihMainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.TESBIHMAINACTIVITY" /> 
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>


    <activity
        android:name="com.tesbih.Splash"
        android:label="@string/app_name" >
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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


  </application>

  </manifest>

此外是我的logcat

  

02-23 20:33:40.713:E / AndroidRuntime(5683)android.content.ActivityNotFoundException:找不到处理Intent的活动{act = com.tesbih.TESBIHMAINACTIVITY}

3 个答案:

答案 0 :(得分:1)

开始你的活动,

Intent openStartingPoint = new Intent (Splash.this,TesbihMainActivity.class);
startActivity(openStartingPoint);

而不是Timer,您也可以使用处理程序进行启动。

new Handler().postDelayed(new Runnable() {

           @Override
           public void run() {
               Intent i = new Intent(SplashScreen.this, TesbihMainActivity.class);
                startActivity(i);

                // close splash
                finish();
            }
}, SPLASH_TIME_OUT);

答案 1 :(得分:1)

android:name="com.tesbih.TesbihMainActivity"
你有清单上面所以你必须改变 splash.java中的("com.tesbih.TESBIHMAINACTIVITY");("com.tesbih.TesbihMainActivity");

答案 2 :(得分:1)

您可以复制并粘贴下面显示的内容

package com.tesbih;

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

public class Splash extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(R.layout.splash);
        Thread timer = new Thread(){

            public void run(){
                try{
                    sleep(3000);
                }catch(InterruptedException e){

                    e.printStackTrace();

                }finally{

                    Intent i = new Intent (Splash.this,TesbihMainActivity.class);
                    startActivity (i);                          
                }
           }     
        };
        timer.start();
    }
 }