마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

splash보다 main화면이 먼저뜨는 이유???

0 추천

아래의 소스 입니다...

splash보다 메인화면이 먼저뜨고 다시 

 

main-> splash -> main 이런식으로 출력이 됩니다....

 

원래는 splash 뜨고 main으로 넘어가는 걸로 구현하고 있는데... 왜 이런지 모르겠네요 ㅠㅠㅠ

 

main

package com.example.test;

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


public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		startActivity(new Intent(this, SplashActivity.class));
		setContentView(R.layout.activity_main);


	}
}

 

splash

package com.example.test;

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

public class SplashActivity extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                finish();       
            }
        }, 2000);// 2 초
    }
}

main activity

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.test.MainActivity" >


</RelativeLayout>

splash.xml

 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:sl="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

       <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1920"
        android:background="@drawable/kuvings_splah">
    
        </LinearLayout>

</LinearLayout>

 

androidmanifest

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

    <uses-sdk
        android:minSdkVersion="18"/>
	
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        
        <activity 
            android:name="com.example.test.SplashActivity"
  		    android:screenOrientation="portrait"
  		    android:configChanges="orientation|keyboardHidden"
   		    android:theme="@android:style/Theme.NoTitleBar">
         </activity>
        
        <activity
            android:name=".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>
        
 
  
        
        
    </application>

</manifest>

 

 

쿠쿠부다스 (6,470 포인트) 님이 2017년 7월 24일 질문

2개의 답변

0 추천

<activity

            android:name=".MainActivity"

            android:screenOrientation="portrait"

            android:configChanges="orientation|keyboardHidden"

            android:theme="@android:style/Theme.NoTitleBar">

         </activity>

         

        <activity

            android:name=".SplashActivity"

            android:label="@string/app_name" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

 

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

            </intent-filter>

        </activity>

//startActivity(new Intent(this, MainActivity.class));

익명사용자 님이 2017년 7월 24일 답변
0 추천
<intent-filter>

                <action android:name="android.intent.action.MAIN" />

 

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

            </intent-filter>

라는 인텐트 필터가 들어있는 액티비티가 가장 처음에 호출됩니다~
겸군님 (1,900 포인트) 님이 2017년 7월 24일 답변
...