티스토리 뷰
출처 : http://blog.naver.com/brainkorea/150146115713
--------------------------------------------------------
원글 : http://www.androidpub.com/index.php?mid=android_dev_qna&page=47&document_srl=1698272
1.앱이설치된 경우
html에서 iframe 을 이용하여 앱을 호출하는걸 아이프레임에 넣어놓고 호출시에는
브라우저가 닫히고 앱이 실행되고
2.앱이 설치되지 않은 경우
아이프레임상에서 오류페이지가 뜰경우
부모 html에 스크립트로 setTimeout 몇초간 줘서
브라우저가
0.5초동안 닫히지 않을시 어플다운로드 페이지로 이동하도록 해서 처리하였습니다.
여기서 iframe 는 눈에 보이지 않도록 width=0 height=0 설정하였습니다.
<script>
function checkApplicationInstall() {
document.checkframe.location = "myapp://check_install";
setTimeout("checkApplicationInstall_callback()", 1000);
}
function checkApplicationInstall_callback() {
try {
var s = document.checkframe.document.body.innerHTML;
// 어플리케이션 설치되어있음
} catch (e) {
// 어플리케이션 설치 안 되어있음
}
}
</script>
<input type="button" value="check app install" onclick="checkApplicationInstall()"/><br/>
<iframe id="checkframe" name="checkframe" src="check.html" width="1" height="1"></iframe>
<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="check_install" />
</intent-filter>
---------------------------------------------------
checkApplicationInstall_callback 에서 전역변수 Intalled = true로 주어서
설치여부를 확인할 수도 있겠죠-
'program' 카테고리의 다른 글
linux 에서 gcc,g++,glibc 설치하기 (0) | 2015.10.14 |
---|---|
모바일웹에서 App 실행 및 설치여부 확인 (1) | 2015.05.18 |
특정 앱 설치 여부 확인 및 마켓 이동 소스 (0) | 2015.05.18 |
Mobile Web에서 APP 설치 여부 판단 (0) | 2015.04.20 |
url-shortener (0) | 2015.04.15 |