[AOS] Android DeepLink ์ค์
๋ฅ๋งํฌ๋
๋ฅ ๋งํฌ๋ ์ฌ์ฉ์๋ฅผ ์ฑ์ ํน์ ์ฝํ ์ธ ๋ก ๋ฐ๋ก ์ฐ๊ฒฐํ๋ URL์ด๋ค.
์ฐ๊ฒฐ์ ์ํ๋ activity์ intent filter์ ๋ฅ ๋งํฌ๋ฅผ ์ค์ ํ๋ฉด deeplink๋ฅผ ๋๋ฅธ ์ฌ์ฉ์์๊ฒ ํด๋น activity๋ฅผ ๋์์ค๋ค.
๋ฅ๋งํฌ ๋ง๋ค๊ธฐ
์ฑ ์ฝํ ์ธ ๋ฅ ๋งํฌ ๋ง๋ค๊ธฐ | Android ๊ฐ๋ฐ์ | Android Developers
์ฌ์ฉ์๊ฐ ๋งํฌ์์ ์ฑ์ ์ง์ ํ ์ ์๋๋ก ํ๋ ค๋ฉด ๊ด๋ จ ํ๋์ ์ธํ ํธ ํํฐ๋ฅผ ์ฑ manifest์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ์ด๋ฌํ ์ธํ ํธ ํํฐ๋ ๋ชจ๋ ํ๋์ ์ฝํ ์ธ ๋ก ์ฐ๊ฒฐ๋๋ ๋ฅ ๋งํฌ๋ฅผ ํ์ฉ…
developer.android.com
1. ์ปค์คํ scheme, host ๊ฐ ์ ์
ํธ์๋ฅผ ์ํด string.xml์ scheme๊ณผ host ๊ฐ์ ์ ์ํด์ค๋ค.
<resources>
...
<string name="deeplink_scheme">deeplink</string>
<string name="deeplink_host">main</string>
</resources>
2. AndroidMenifest.xml ์ค์
๋ฅ๋งํฌ์ ์ฐ๊ฒฐ๋์ด ํ๋ฉด์ ์ถ๋ ฅํ activity์ VIEW action๊ณผ BROWSSABLE, DEFAULT ์นดํ ๊ณ ๋ฆฌ๋ฅผ ํฌํจํ๋ค.
๋ํ URI ํ์์ ๋ํ๋ด๋ data ํ๊ทธ์ ์์์ ์ ์ํ scheme๊ณผ host๋ฅผ ๋ฃ์ด์ค๋ค.
<application
...>
<activity
...>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="@string/deepilnk_host"
android:scheme="@string/deeplink_scheme" />
</intent-filter>
</activity>
...
</application>
Deeplink ํ ์คํธ ํด๋ณด๊ธฐ
* ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์ด์ฉํ ํ ์คํธ ์ ๋๋ค.
Android ๋๋ฒ๊ทธ ๋ธ๋ฆฌ์ง(adb) | Android ๊ฐ๋ฐ์ | Android Developers
๊ธฐ๊ธฐ์ ํต์ ํ ์ ์๋๋ก ์ง์ํ๋ ๋ค๋ชฉ์ ๋ช ๋ น์ค ๋๊ตฌ์ธ Android ๋๋ฒ๊ทธ ๋ธ๋ฆฌ์ง์ ๋ํด ์์๋ณด์ธ์.
developer.android.com
1. ์คํ๋์ด ์๋ ์๋ฎฌ๋ ์ดํฐ ํ์ธํด๋ณด๊ธฐ
List of devices attached
emulator-5556 device
์๋ฎฌ๋ ์ดํฐ๊ฐ ์คํ๋์ด ์์ง ์์ ๊ฒฝ์ฐ
adb: device offline
์์ ๊ฐ์ด ์คํ๋์ด ์๋ ์๋ฎฌ๋ ์ดํฐ๊ฐ ์๋ ๊ฒฝ์ฐ ๋นํฉํ์ง ์๊ณ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์ผ์ฃผ๋ฉด ๋๋ค.
์คํ๋์ด ์๋ ์๋ฎฌ๋ ์ดํฐ๊ฐ ์ฌ๋ฌ๋์ธ ๊ฒฝ์ฐ
List of devices attached
emulator-5556 device
emulator-5558 device
์๋ ๋ช ๋ น์ด๋ฅผ ์คํํด ํน์ ์๋ฎฌ๋ ์ดํฐ shell์์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ ์ ์๋๋ก ํ๋ค.
2. deeplink ์คํ ๋ช ๋ น์ด
Starting: Intent { act=android.intent.action.VIEW dat=test://main?name=test!! pkg=com.๋ฅ๋งํฌ.ํ๋ก์ ํธ.ํจํค์ง๋ช }
Status: ok
LaunchState: WARM
Activity: com.๋ฅ๋งํฌ.ํ๋ก์ ํธ.ํจํค์ง๋ช .activity.MainActivity
TotalTime: 907
WaitTime: 914
Complete
์ค๊ฐ์ "deeplink://main?name=test!!" ์์
deeplink๋ ์์์ string.xml์ ์ ์ํ scheme๊ฐ, main์ host ๊ฐ์ด๋ค.
name=test!!๋ ํด๋น activity์ ์ ๋ฌํ ๋ฐ์ดํฐ, ์ฆ name์ด๋ผ๋ intent์ test!!๋ผ๋ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌํด ์ฃผ๋ ์ญํ ์ ํ๋ค.
adb: more than one device/emulator
๋ช ๋ น์ด ์คํ ํ ์์ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ฉด ์์์ ์ธ๊ธํ ์คํ๋์ด ์๋ ์๋ฎฌ๋ ์ดํฐ๊ฐ ์ฌ๋ฌ๋์ธ ๊ฒฝ์ฐ์ด๊ธฐ ๋๋ฌธ์ ํน์ ์๋ฎฌ๋ ์ดํฐ shell์์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ ์ ์๋๋ก ์ค์ ํด์ฃผ์ด์ผ ํ๋ค.
์ค์ ํ deeplink์ scheme์ด ๋ค๋ฅธ ์ฑ๊ณผ ๊ฒน์น๋ฉด
์์ ๊ฐ์ด ๋ฅ๋งํฌ๊ฐ ์ผ์นํ๋ ์ดํ๋ฆฌ์ผ์ด์ ๋ค ์ค์์ ์ํ๋ ์ฑ์ ์ ํํด์ผ ํ๋ ์ํฉ์ด ๋ฐ์ํ๊ธฐ๋ ํ๋ค.
์ด๋ฌํ ์ํฉ์ ๋ฐฉ์งํ ์ ์๋ ๋ฐฉ๋ฒ์ ๋ฅ๋งํฌ์ ์ผ์ข ์ธ ์ฑ๋งํฌ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด ์๋ค.
์ฑ๋งํฌ๋ ๋๋ฉ์ธ ์ฃผ์๋ฅผ ์ด์ฉํ ๋ฅ๋งํฌ๋ก, ์์์ ๋ค๋ฃฌ ์คํด์ ์ด์ฉํ ๋ฅ๋งํฌ๋ฅผ ๋ฑ๋กํ๋ ๊ฒ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก AndroidMenifest์์ ํด๋น activity์ intent-filter๋ฅผ ์ค์ ํด์ฃผ๋ฉด ๋๋ค.
์ฑ๋งํฌ ์ธ์๋ ์ ๋๋ฒ์ ๋งํฌ๊ฐ ์๋ค.
ํ๋์ ๋ฅ๋งํฌ๋ง์ผ๋ก๋ ๋ชจ๋ ํ๊ฒฝ์ ๋์ํ์ง ๋ชปํ๊ธฐ ๋๋ฌธ์ ์ต์ ์ ์ฌ์ฉ์ ๊ฒฝํ์ ์ํด์๋ 3๊ฐ์ ๋ฅ๋งํฌ ๋ฐฉ์์ ์ฑํํ์ฌ ์ํธ ๋ณด์์ ์ผ๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ์ข๋ค.