2017-08-15 3 views
0

Ich entwickle eine App auf Android, die stark von der Funktion des GPS-Plugins abhängt, aber nach 2 Anrufe an die GPS hört das auf zu arbeiten. Ich muss Google Maps öffnen, damit das Plugin wieder funktioniert.Cordova Geolocation-Plugin funktioniert manchmal

Ich teste auf Samsung J1 und huawei G5 (Android 5.1.1), cordova v7.0.0 und Geolocation Plugin-Version 2.4.2

Antwort

0

ich die Lösung in einer anderen Frage gefunden, überprüfen Sie es here

dank user2147549, alle Kredite an ihn.

das ist, was Arbeit in meinem Fall:

auf cordova v5.3.3, müssen Sie dies tun:

1, cordova Plugin cordova-Plugin-Geolocation

2, cordova Plugin entfernen cordova-Plugin-Geolocation

3, kopieren Sie Ihre cordova-plugin-Geolocation-Verzeichnis in Ihrem plguins dir zu e hinzu: \

4, bearbeiten Plugi n.xml, fügen diese: \ Cordova-Plugin-geolocation

7, Cordova run android:

<js-module src="www/Coordinates.js" name="Coordinates"> 
    <clobbers target="Coordinates" /> 
</js-module> 

<js-module src="www/PositionError.js" name="PositionError"> 
    <clobbers target="PositionError" /> 
</js-module> 

<js-module src="www/Position.js" name="Position"> 
    <clobbers target="Position" /> 
</js-module> 

<js-module src="www/geolocation.js" name="geolocation"> 
    <clobbers target="navigator.geolocation" /> 
</js-module> 

<config-file target="res/xml/config.xml" parent="/*"> 
    <feature name="Geolocation"> 
     <param name="android-package" value="org.apache.cordova.geolocation.GeoBroker"/> 
    </feature> 
</config-file> 

<config-file target="AndroidManifest.xml" parent="/*"> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 
</config-file> 

5, Cordova Plugin Cordova-Plugin-geolocation

6, Cordova Plugin hinzufügen e entfernen Jetzt habe ich gute GPS-Position. Danke für WuZhonghua.

0

Es stellt sich heraus, dass dieses Problem mit einer älteren Version des Plugins gelöst werden kann.

In meinem Fall brauche ich nur die Cordova App, um auf Android zu arbeiten, so dass kein Problem ist.

müssen Sie GPS-Plugin, um Ihre proyect wie folgt hinzuzufügen:

cordova plugin add [email protected] 
Verwandte Themen