'현재위치'에 해당되는 글 1건

  1. 2013.07.03 webview에서 googlemap 현재위치 불러오기
android2013. 7. 3. 11:35

일단 현재 위치를 받기위해선  GeolocationPermissions.Callback를 implements 시킨다

( public class 클래스명 extends Activity implements GeolocationPermissions.Callback )


웹뷰 세팅 부분

WebSettings setting = web.getSettings();

setting.setJavaScriptEnabled(true); // 웹뷰에서 자바스크립트 실행 가능

web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

web.getSettings().setGeolocationEnabled(true);    // 현재위치 연결


String url = "연결 주소";

GeoClient geo = new GeoClient();

web.setWebChromeClient(geo);

String origin = ""; // how to get origin in correct format?

geo.onGeolocationPermissionsShowPrompt(origin, this); // obviously not how this is meant to be used but                 

  // expected usage not documented

web.loadUrl(url);




public void invoke(String origin, boolean allow, boolean remember) {


}


final class GeoClient extends WebChromeClient {


@Override

public void onGeolocationPermissionsShowPrompt(String origin,

Callback callback) {

// TODO Auto-generated method stub

super.onGeolocationPermissionsShowPrompt(origin, callback);

callback.invoke(origin, true, false);

}


}



출처 : http://stackoverflow.com/questions/2267513/using-navigator-geolocation-getcurrentposition-in-webview-on-android-2-0-phone

Posted by 광포한곰돌이