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

[android] Browser 의 링크를 통해 내 앱 실행시키기

by 돼지왕 왕돼지 2013. 11. 6.
반응형


 android, Browser 의 링크를 통해 내 앱 실행시키기

 

[android] Browser 의 링크를 통해 내 앱 실행시키기



Declare Intent-filter on Manifest


The activity which wants to be started has to have action name "android.intent.action.VIEW".

Additionally, it has two basic category; they are android.intent.category.DEFAULT and android.intent.category.BROWSABLE.

To link the url to the activity, intent-filter has to have data and it declares one or some of followings : scheme, host, port, path.


<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:scheme="myapp" android:host="myapp.com"/>

</intent-filter>




For testing.


<html>

      <body>

          <a href="myapp://myapp.com">Click to lead apk</a>

      </body>

</html>


Keep it mind that WebView with manual html document does not support such a link.

You should try this one on the real web page.





How to get additional info?


Via getIntent().getData() you can get uri.

So if you want to pass some parameters, you can just add it with the agreement of the app developer.






반응형

댓글