woong's

Android Launcher 만들기(1) 본문

Develop/Android

Android Launcher 만들기(1)

dlsdnd345 2016. 2. 14. 13:08
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Android Launcher 만들기(1)


안녕하세요. 이번에 기회가 생겨 안드로이드 런쳐 공부를 하고 있습니다.

안드로이드의 끝판왕이라고 불리는 런쳐 ... 어디까지 만들수 있을지는 모르겠지만 ,

하나하나 해보려 합니다.


안드로이드 런쳐 Hello World 를 해보려 합니다 .


안드로이드 앱을 런쳐 형태로 사용하려면 


manifast 파일의 intent filter 를 추가해야 합니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="utf-8"?>
    package="com.woong.baselauncher" >
 
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <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"/>
                <category android:name="android.intent.category.HOME"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
    </application>
 
</manifest>
 
cs

 


핵심 코드는 하단 두줄이 되겠습니다.

1
2
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
cs


이와 같이 설정을 하면 홈버튼을 누를시 해당 앱을 실행하게 됩니다.

그럼 런처의 기본 형태는 갖추게 되는것입니다. 


하지만 앱을 뒤로가기를 선택하면 앱이 종료 됩니다.

런처앱은 종료 되지 않아야 하기 때문에 


1
2
3
4
@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return false;
    }
cs


런처 홈에서는 앱이 꺼지지 않을수 있도록 뒤로가기 키를 막아주면 되겠습니다.


이와 같이 진행하시면 Hello World 런처 기본 앱을 만들수 있습니다 . 


Comments