본문 바로가기
프로그래밍 놀이터/안드로이드, Java

[android] Intent Filter 를 이용하여 link 처리하기.

by 돼지왕 왕돼지 2013. 9. 19.
반응형


 안드로이드, Intent Filter 를 이용하여 link 처리하기.

 


[android] Intent Filter 를 이용하여 link 처리하기.


간혹가다 보면, 일반 url 을 클릭했을 뿐인데 Google Map Activity 가 뜨는 것을 본 적이 있을 것이다.

분명 link 를 클릭했다면 브라우저가 떠야 하는데 말이다.

사실 브라우저가 해당 link 를 처리하는 것보다는 Map App 에서 처리하는 것이 훨씬 효율적이라는 것은 모두가 공감할 것이다.


그럼 특정 상황 & link 에 대해서 앱이 이를 처리하게 하려면 어떻게 해야할까?

답은 제목에서도 알 수 있듯이 intent filter 를 이용하여 처리할 수 있다.


<activity android:name=".MyActivity">

<intent-filter>

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

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

<data android:scheme="http"

      android:host="myhost.com"

      android:pathPrefix="/maps/" />

</intent-filter>

</activity>





위와 같이 BROWSABLE 로 category 를 두어 link 를 가로챌 수 있도록 해주고,

data 에 scheme, host, pathPrefix 등을 넣어 주어서 특정 링크 형태들에 대해 가로채도록 한다.


자 도전!!



반응형

댓글