Notice
Recent Posts
Recent Comments
Link
달팽이웰니스
Web2App 호출 본문
Web2App 호출
ref.
Android 디버그 브리지(adb) | Android Studio | Android Developers
Android 디버그 브리지(adb) | Android Studio | Android Developers
기기와 통신할 수 있도록 지원하는 다목적 명령줄 도구인 Android 디버그 브리지에 대해 알아보세요.
developer.android.com
1. 연동 방식

-
WebView에 웹 페이지를 띄워 Web to App 통신 후에 기존 샘플처럼 App to App 통신하는 방식.
Ref.
WebView에서 웹 앱 빌드 | Android Developers
WebView에서 웹 앱 빌드 | Android Developers
이 페이지는 Cloud Translation API를 통해 번역되었습니다. WebView에서 웹 앱 빌드 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. WebView를 사용하여 웹 애플리케이
developer.android.com
WebView.getSetting().setJavaScriptEnabled(true);
WebAppInterface webAppInterface = new WebAppInterface(context);
webView.addJavascriptInterface(webAppInterface, "AndroidBridge");
webView.loadUrl("file:///android_asset/index.html");
public class WebAppInterface {
private Context context;
public WebAppInterface(Context context){
this.context = context;
}
@JavascriptInterface
public void sendMessageToNative(String msg) throws JSONException {
// 웹에서 보낸 메시지를 처리
JSONObject jsonObject = new JSONObject(msg);
// JSON 객체에서 데이터 추출
String inTestMode = jsonObject.getString("inTestMode");
//Intent Request
Spec.RequestData(intent);
intent.putExtra("ResultType", 0);
startActivityForResult(intent, 3000);
}
}
}
반응형
'tech' 카테고리의 다른 글
[window11][윈도우] 가상메모리 설정 (0) | 2025.01.27 |
---|---|
2024년 6대 과학기술 주력분야 주요뉴스 발표 (0) | 2025.01.27 |
.Net 6.0 에서 NullReferenceException 인 경우 (0) | 2025.01.22 |
visual studio 2022에서 CS0234 오류인 경우 (0) | 2025.01.22 |
Connecting websocket from Flutter (0) | 2025.01.22 |