启动我的应用程序时,应将几个POI坐标添加到Android系统.几个小时后,我的应用程序关闭,用户走近其中一个POI,他将收到通知,例如通过状态消息.
是这对我的方案是正确的做法?Android中有更多可用的东西来实现这一目标吗?
public void addProximityAlert(double latitude,double longitude,float radius,long expiration,PendingIntent intent)
android location-aware location-based-service android-location android-alarms
我正在开发一个应用程序,它更像是你朋友之间的时移赛.
我需要计算移动车辆的速度,我不想使用Location.getSpeed()方法.(在底部详细解释为什么我不想使用它)
我试图通过Latitude and Longitude帮助计算速度,这是我需要帮助的地方.
需要的帮助:我想知道的是:
我使用以下代码:
这给了我两个LatLng点之间的距离:
long getDistanceBetweenPoints(double lat1, double lng1, double lat2, double lng2 ){
        double dLat = Math.toRadians(lat2 - lat1);
        double dLon = Math.toRadians(lng2 - lng1);
        double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
                + Math.cos(Math.toRadians(lat1))
                * Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 2)
                * Math.sin(dLon / 2);
        double c = 2 * Math.asin(Math.sqrt(a));
        long distanceInMeters = Math.round(6371000 * c);
        return distanceInMeters;
    }
以下代码是如何使用它:
if(lastLat == -1 && lastLng == …我正在尝试测试GeoFences的位置感知应用程序.我已经获得了多达11次连续成功,但通常会有数十次失败.重新启动设备没有帮助.卸载/重新安装没有帮助.禁用位置,重新启用位置无济于事.更改设备位置准确度设置没有帮助.
我已经在v2.3.4,v4.0.3,v4.4.2,v4.4.4和2 v5.0.1物理设备上进行了测试.其中一个Lollipop设备是具有蜂窝服务的设备.其余设备是SIMless的,仅用于测试.旁注:没有服务的设备很难通过MockLocation设置它们的位置,但是如果他们设法设置它们的位置,他们几乎从不注册围栏入口/出口.
位置正在通过Mock Location更新,但GeoFence不会被任何可靠性触发.
我用谷歌搜索了它.我查看了developer.android.com网站上的文档.我搜索过StackOverflow.事实上,其他人提出的许多建议已在下面的代码中实现.
那么,我如何使用MockLocation可靠地触发我的GeoFence?
import android.location.Location;
import android.location.LocationManager;
public class GeoFenceTester extends ActivityInstrumentationTestCase2<GeoFenceTesterActivity> {
    public static final String TAG = GeoFenceTester.class.getSimpleName();
    private LocationManager locationManager;
    private Activity activityUnderTest;
    protected void setUp() throws Exception {
        super.setUp();
        activityUnderTest = getActivity();
        /*
            MOCK Locations are required for these tests.  If the user has not enabled MOCK Locations
            on the device or emulator these tests cannot work.
         */
        if (Settings.Secure.getInt(activityUnderTest.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION, 0) == 0) {
            throw new RuntimeException("Mock locations are currently disabled …android unit-testing geolocation android-location geofencing
我正在开发一个我想使用Fused Location Provider的应用程序.但我有一些疑问,还有几个问题.
你有什么意见?提前致谢.
我希望每隔一定分钟进行一次硬位置修复,每隔一定分钟进行一次软位置修复,并且如果用户移动的距离超过一定米数。我一直在用下面的代码步行来测试逻辑(在驾驶时也尝试使用更大的参数),但它并没有真正返回我定期的位置修复。当请求开始时,它会立即返回位置修复,然后有时会在几分钟后返回 1 个位置修复,但随后长达一个小时,它不会返回位置修复。
LocationRequest locationRequest = LocationRequest.create();
int priority = PRIORITY_BALANCED_POWER_ACCURACY;
locationRequest.setPriority(priority);
locationRequest.setInterval(localInterval); //set to 6 minutes
locationRequest.setFastestInterval(localFastestInterval); //set to 3 minutes
locationRequest.setSmallestDisplacement(smallestDisplacement); //set to 10 meters
locationRequest.setNumUpdates(numUpdates);  //set to Int.MAX_VALUE
locationRequest.setExpirationDuration(expirationDuration); // set to Long.MAX_VALUE
LocationServices.FusedLocationApi.requestLocationUpdates(locationClient, locationRequest, pendingIntent);
如果我将位移设置为 0,那么我会得到定期位置更新。知道发生了什么事吗?
android location android-location fusedlocationproviderapi android-fusedlocation
当我在 Google Play 上更新我的应用程序时,我看到了一条关于我以前从未见过的名为“敏感应用程序权限”的警告。它似乎与通话、短信、位置和文件访问权限有关。
Google Play 上的权限声明表说
位置权限
未启动 您的应用不合规
我的应用程序使用Flutter Location 插件和Flutter Map 插件。我在清单中请求INTERNET和ACCESS_FINE_LOCATION权限:
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
进一步阅读在后台请求访问位置提供了有关 Google Play 政策即将更改的更多信息:
审查和批准变更的时间表
从 2020 年 9 月 30 日开始,我们将开始审查请求在后台访问位置信息的应用。如果您的应用受到影响,您会在 Play 管理中心的应用内容页面(政策 > 应用内容)上收到通知,以完成权限声明表。
从 2021 年 1 月 18 日开始,所有提交到 Google Play 的新应用(2020 年 4 月 16 日之后首次发布)都需要在后台访问位置获得批准才能上线。
从 2021 年 3 月 29 日开始,所有在后台访问位置的现有应用(2020 年 4 月 16 日之前首次发布)都需要获得批准,否则将从 Google Play …
android android-location google-play android-permissions flutter
模拟位置在 Android 10 上不起作用,调用 addTestProvider 时崩溃:
2020-11-30 00:25:16.855 13189-13256/br.com.tupinikimtecnologia.fakegpslocation E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-2
    Process: br.com.tupinikimtecnologia.fakegpslocation, PID: 13189
    java.lang.IllegalArgumentException: Provider "gps" already exists
        at android.os.Parcel.createException(Parcel.java:2075)
        at android.os.Parcel.readException(Parcel.java:2039)
        at android.os.Parcel.readException(Parcel.java:1987)
        at android.location.ILocationManager$Stub$Proxy.addTestProvider(ILocationManager.java:2022)
        at android.location.LocationManager.addTestProvider(LocationManager.java:1461)
        at br.com.tupinikimtecnologia.fakegpslocation.feature.mock.view.MapsActivity.setMock(MapsActivity.kt:100)
        at br.com.tupinikimtecnologia.fakegpslocation.feature.mock.view.MapsActivity.access$setMock(MapsActivity.kt:34)
        at br.com.tupinikimtecnologia.fakegpslocation.feature.mock.view.MapsActivity$onCreate$1.invokeSuspend(MapsActivity.kt:65)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
     Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.LocationManagerService.addTestProvider(LocationManagerService.java:3536)
        at android.location.ILocationManager$Stub.onTransact(ILocationManager.java:958)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)
2020-11-30 00:25:16.857 13189-13256/br.com.tupinikimtecnologia.fakegpslocation I/Process: Sending signal. PID: 13189 SIG: 9
代码:
override fun onCreate(savedInstanceState: Bundle?) { …最近我的应用程序出现问题,Google Play因为他们发现我正在使用后台位置而突然被拒绝。但实际上我没有使用这个功能。我只有ACCESS_COARSE_LOCATION和ACCESS_FINE_LOCATION权限,我正在使用FusedLocationProviderClient我的应用程序获取位置。此位置仅由应用程序内的用户操作请求,因此如果它在后台,则永远不会调用。我检查了合并清单功能,并尝试查找我导入的某些库是否使用了后台位置权限,但我什么也没找到。我还预防性地添加<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove"/>到我的清单中以阻止任何后台位置权限请求。我根本没有任何与位置有关的后台服务。唯一的后台服务FirebaseMessagingService用于推送通知。
最近有人有这个问题吗?
更新:
我在我的应用程序中检查了合并清单,但在那里找不到ACCESS_BACKGROUND_LOCATION权限。但是我发现了一些可以触发后台位置的服务,但我不确定。它们是 Firebase Crashlytics 的一部分,可能用于将数据发送到 Firebase,并且可以在后台工作。但我不认为他们正在发送任何位置。它们也是来自 Google 的 firebase 插件的一部分。
 <service
        android:name="com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService"
        android:exported="false"
        android:permission="android.permission.BIND_JOB_SERVICE" >
    </service>
    <receiver
        android:name="com.google.android.datatransport.runtime.scheduling.jobscheduling.AlarmManagerSchedulerBroadcastReceiver"
        android:exported="false" />
更新#2:
这是我用来获取位置的代码。
主要活动:
     /**
     * Updating location every second/1 meter
     */
    var currLocation: GpsLocation? = null
    private var locationManager : LocationManager? = null
    private fun initLocationManager() {
        if (app.hasLocationPermission){
            locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
        }
        changeLocationUpdaters(true)
    }
    private fun …android android-manifest android-location android-permissions android-fusedlocation
不知何故,构建崩溃并出现与位置组件相关的奇怪错误,该错误位于“src..\location\FlutterLocationService.kt:”中
这是错误:
e: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\location-4.3.0\android\src\main\java\com\lyokone\location\FlutterLocationService.kt: (124, 1): Class 'FlutterLocationService' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
我正在尝试创建一个更新当前gps位置的后台服务.我正在NullPointerException排队LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
HomeActivity推出了一项服务
startService(new Intent(getApplicationContext(), ForHire.class));
Service(ForHire)创建TimerTask更新
public class ForHire extends Service {
...
private Timer getUpdatesNow = new Timer();
private Updates updates = new Updates(getUpdatesNow);
@Override
public void onCreate() {
    ...
    getUpdatesNow.schedule(updates, God.KM20TIME);
    Log.v("Taxeeta", "Notification created");
}
    private class Updates extends TimerTask implements LocationListener {
    private Timer getUpdatesNow;
    public Updates(Timer newGetUpdatesNow) {
        super();
        getUpdatesNow = newGetUpdatesNow;
        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                God.KM20TIME, God.KM20DISTANCE, (LocationListener) this);
    }
    public void run() {
        ...
        //do …android ×10
android-location ×10
flutter ×2
geolocation ×2
gps ×2
android-maps ×1
geofencing ×1
google-play ×1
location ×1
mocking ×1
unit-testing ×1