gpt4 book ai didi

java - NETWORK_PROVIDER 未提供位置更新

转载 作者:行者123 更新时间:2023-12-01 15:48:08 25 4
gpt4 key购买 nike

我的程序运行良好,但突然 NETWORK_PROVIDER 停止提供位置更新。如果启用 WIFI,它也不起作用。有人知道为什么吗?

谢谢!

这是一些(加密的)Java:

package com.tripr;

public class MyWallpaperService extends WallpaperService{



<snip>


@Override
public Engine onCreateEngine() {
return new CubeEngine(this);
}


class CubeEngine extends Engine implements LocationListener{

private MyWallpaperService mws;
private LocationManager lm;


<snip>


CubeEngine(MyWallpaperService mymws) {
mws = mymws;

lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
requestLocationUpdates();
MyThread myThread = new MyThread(lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER));
myThread.start();
}

void requestLocationUpdates(){
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000*30, 10, this);
}

void removeUpdates(){
lm.removeUpdates(this);
}


@Override
public void onLocationChanged(Location location) {
MyThread myThread = new MyThread(location);
myThread.start();

}

<snip>
}

和 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tripr"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />


<uses-feature android:name="android.software.live_wallpaper" />

<application android:icon="@drawable/icon" android:label="@string/app_name">

<service android:name=".MyWallpaperService"
android:label="@string/app_name"
android:icon="@drawable/icon"
android:permission="android.permission.BIND_WALLPAPER">

<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper"
android:resource="@xml/livewallpaper" />

</service>

</application>
</manifest>

最佳答案

为了确保 NETWORK_PROVIDER 是否可以像这样进行操作检查,

if(isLocationProviderEnabled(LocationManager.NETWORK_PROVIDER))
{
Log.i("PROVIDER", "ENABLED");
}

关于java - NETWORK_PROVIDER 未提供位置更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6711521/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com