簡體   English   中英

我無法使用Android Splash Screen啟動我的應用程序

[英]I can't start my application with Android Splash Screen

我正在嘗試將閃屏活動添加到我的android應用程序中,我正在做我在互聯網上的所有課程,但沒有用。 它總是說“不幸的是, *已停止。” 可能是什么原因?

謝謝..

我的主要活動

<code>package com.fckirbay.istatistikelkitap;

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

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.acilis);

        Thread thread = new Thread() {

            @Override
            public void run() {

                try {
                    synchronized (this) {
                        wait(4000);
                    }
                } catch (InterruptedException e) {

                    // Hata yönetimi

                } finally {

                    finish();

                    // Yeni açılmak istenen Intent
                    Intent intent = new Intent();
                    intent.setClass(getApplicationContext(), acilis.class);
                    startActivity(intent);

                }

            }
        };

        // Thread başlatılıyor
        thread.start();

    }
}</code>

mysplash屏幕

package com.fckirbay.istatistikelkitap;

import com.fckirbay.istatistikelkitap.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;


public class acilis extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button tablolar=(Button)findViewById(R.id.tablolar);   
        Button istatistikciler=(Button)findViewById(R.id.istatistikciler);   
        Button unite1=(Button)findViewById(R.id.unite1);   
        Button unite2=(Button)findViewById(R.id.unite2);
        Button unite3=(Button)findViewById(R.id.unite3);   
        Button unite4=(Button)findViewById(R.id.unite4);
        Button unite5=(Button)findViewById(R.id.unite5);
        Button unite6=(Button)findViewById(R.id.unite6);
        Button devam=(Button)findViewById(R.id.devam);

        devam.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.EKRANIKI"));
            }
        });

        tablolar.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.TABLOLAR"));
            }
        });

        istatistikciler.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.ISTATISTIKCILER"));
            }
        });

        unite1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE1"));
            }
        });

        unite2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE2"));
            }
        });

        unite3.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE3"));
            }
        });

        unite4.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE4"));
            }
        });

        unite5.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE5"));
            }
        });

        unite6.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE6"));
            }
        });





    }



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

和活動清單

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.fckirbay.istatistikelkitap"
    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="com.fckirbay.istatistikelkitap.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="com.fckirbay.istatistikelkitap.acilis"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.ACILIS" />

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

     </application>

</manifest>

在清單文件中,應用程序入口點應為MainActivity。

清單文件中應該包含類似以下內容的內容。

<activity
        android:name="com.example.MainActivity"
        android:label="@string/app_name" android:screenOrientation="landscape" android:configChanges="keyboard|keyboardHidden|orientation" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

好的,試試這個:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fckirbay.istatistikelkitap"
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="com.fckirbay.istatistikelkitap.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="Acilis" />

    </activity>

 </application>

</manifest>

問題是您定義了兩個啟動器活動。 將您的Splash活動設置為LAUNCHER和MainActivity DEFAULT。

對於您的啟動活動:

<category android:name="android.intent.category.LAUNCHER" 

對於您的主要活動:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM