我必须在a中检索用户的位置WebView.我使用以下Javascript执行此操作:
function getLocation() {
navigator.geolocation.getCurrentPosition(displayLocation, handleError);
}
Run Code Online (Sandbox Code Playgroud)
但是权限请求弹出窗口永远不会打开.
我设置了这些设置:
ws.setJavaScriptEnabled(true);
ws.setGeolocationEnabled(true);
ws.setJavaScriptCanOpenWindowsAutomatically(true);
Run Code Online (Sandbox Code Playgroud)
从一个位置访问用户位置的正确方法是WebView什么?
所以这是我的MyLocationListener类
package com.example.gpslocater;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class MyLocationListener implements LocationListener {
public TextView mLocationTextView;
Context mContent;
public MyLocationListener(Context context) {
mContent = context;
}
@Override
public void onLocationChanged(Location location) {
location.getLatitude();
location.getLongitude();
String Text = "My current location is :" +
"Latitude = " + location.getLatitude() +
" Longitude = " + location.getLongitude();
//figure out a way to make it display through a text view
mLocationTextView.setText(Text);
}
@Override
public void …Run Code Online (Sandbox Code Playgroud)