2012-11-07 5 views
0

휴대 전화의 위치를 ​​확인하고자하는 Adroid 앱을 만들었습니다. 나는 에뮬레이터를 설치하기 시작했고 매번 확인하고 싶다. 실패한다. 에뮬레이터가 문제입니까 (실제 휴대 전화가 아니기 때문에) 또는 제대로하지 않았습니다.build.phonegap.com 안드로이드 앱 버전

<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
     <meta name="format-detection" content="telephone=no" /> 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
       <title>Hello World</title> 
     <script type="text/javascript" src="cordova-2.1.0.js"></script> 
     <script text="text/javascript"> 
     function startUp(){ 
      document.getElementById("H1").innerHTML = "Checking your location..."; 
      document.addEventListener("deviceready", onDeviceReady, false) 
     } 
     function onDeviceReady() { 
     navigator.geolocation.getCurrentPosition(onSuccess, onError); 
    } 

    // onSuccess Geolocation 
    // 
    function onSuccess(position) { 
     var element = document.getElementById('location'); 
     element.innerHTML = 'Latitude: '   + position.coords.latitude    + '<br />' + 
          'Longitude: '   + position.coords.longitude    + '<br />' + 
          'Altitude: '   + position.coords.altitude    + '<br />'; 
          document.getElementById("H1").innerHTML = ""; 
    } 

    // onError Callback receives a PositionError object 
    // 
    function onError(error) { 
     document.getElementById("H1").innerHTML = "Fail to check your location."; 
    } 

     </script> 
    </head> 
    <body style="margin:0px;" onload="startUp()" bgcolor="#000"> 
     <div class="app" style="background-color:#4D4D4D"> 
      <font color="#FF9900" size="2"><h1 id="H1" style="font-family:courier new;"></h1></font> 
      <p id="location"></p> 
     </div> 



    </body> 
</html> 

<?xml version="1.0" encoding="UTF-8" ?> 
    <widget xmlns = "http://www.w3.org/ns/widgets" 
     xmlns:gap = "http://phonegap.com/ns/1.0" 
     id  = "com.park.manager" 
     versionCode="10" 
     version = "0.1.9"> 
    <name>ParkingManager</name> 
    <description> 
     A system, which manages parking side areas. 
    </description> 
    <author href="" email=""> 
     Parking Side Manager Team 
    </author> 
    <preference name="phonegap-version" value="2.1.0" /> 
    <preference name="orientation" value="landscape" /> 
    <preference name="target-device" value="universal" /> 
    <preference name="fullscreen" value="true" /> 
    <preference name="android-installLocation" value="auto" /> 
    <icon src="icon.png" /> 
    <gap:splash src="splash.png" /> 
    <feature name="http://api.phonegap.com/1.0/geolocation"/> 
    <feature name="http://api.phonegap.com/1.0/network"/> 

</widget> 

답변

0

이 매니페스트 XML에 당신은 일반 및 미세 위치에 대한 사용 권한을 추가하는 것이 있는지 확인 HTML5 파일과 config.xml에.

전화 차이가 있지만 그 손으로 매니 페스트를해야하는 것과 같은 주요 문제가 해결되지는 않습니다. 이러한 권한을 추가하는 방법을 알기 전에 java로 앱을 만든 경우. 그것을하는 방법을 확인하는 데 사용하지 않는 경우. permissions

코드바 geolaction 호출이 옳다는 것을 제외하고는 예전에 사용했습니다.

0

에뮬레이터는 에뮬레이터가 제대로 작동하기 위해 무엇을 얻을지 알기 때문에 실제 전화가 필요합니다. 귀하의 자바 스크립트와 HTML 괜찮아요.