Android:UrlScheme
안드로이드 URL Scheme 사용방법에 대한 설명.
URL Scheme을 사용한 안드로이드 Activity호출방법
우선, 호출받는(Destination) 어플측에 아래와 같이 AndroidManifest.xml를 수정한다.
<activity
android:name=".BkCalculatorActivity"
android:label="@string/title_activity_calc">
<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="bk" android:host="calc"/>
</intent-filter>
</activity>
중요한 부분은 android:scheme
과 android:host
이다. 위의 예제를 URI로 변환하면 아래와 같다.
이제, 호출받는 어플의 해당 Activity.onCreate()
에 URI데이터를 받을 수 있도록 추가한다.
Uri data = getIntent().getData();
if (data != null) {
String get_op1 = data.getQueryParameter("op1");
String get_op2 = data.getQueryParameter("op2");
}
위의 예제를 URI로 변환하면 아래와 같다.
마지막으로, 호출하는측 Intent조립방법은 아래와 같다.
Uri uri = Uri.parse("bk://calc?op1=100&op2=200");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setAction(Intent.ACTION_VIEW);
startActivity(intent);
See also
Favorite stie
References
-
Blog.daum.net_-mailss-_android_url_scheme.pdf ↩