- 다른 앱에서 호출할 수 있도록 URI scheme을 등록
- 각 Activity마다 Intent-filter를 등록함으로써 URI Scheme를 생성
- Activity의 URI Scheme는 {shcheme}://{host}
A app의 AndroidMenifest.xml
<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" /> <!-- host : 이동할 페이지(액티비티) scheme : 앱의 이름 --> <data android:host="byunhost" android:scheme="byunscheme" /> </intent-filter>
- 호출할 앱(B app)에서 위에서 등록한 Scheme 정보를 통해 A app을 호출
- 웹 URI을 호출하는 방법과 똑같이 사용
btnAapp.setOnClickListener { String uriScheme = "byunscheme://byunhost"; Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(uriScheme)); startActivity(intent); }
- javascript에서 다음과 같은 코드 호출
"intent://{host}#Intent;scheme={scheme};package={package};end";
<html>` <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width"> </head> <body> <a href ="callScheme()">call scheme</a> </body> </html> <script> function callScheme(){ location.href = "intent://byunhost#Intent;scheme=byunscheme;action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;package=com.example.myapplication;end"; } </script>
[1] https://velog.io/@jeep_chief_14/URL-Scheme-0xm9upiv
[2] https://gomest.tistory.com/7
[3] https://helloit.tistory.com/366