小编Mar*_*eio的帖子

Android服务未收到位置更新

尝试在我的服务中获取LocationUpdates,但它似乎从未触发过LocationListener。

我的服务启动了一个线程,然后该线程与Handler.postDelayed()循环-我最初使用sleep(30000),但是我认为这可能阻止了locationUpdates。所有服务所做的就是启动该线程-并且onStartCommand返回STICKY使其保持运行:

public class TST extends Thread {

    final int DefaultNetworkTick = 120000; // 2 minutes
    final int DefaultLocationTick = 20000; //600000;  
    boolean CustomLocationUpdateTick = false; // If the network requests faster updates
    int CustomLocationUpdateTickMs = 600000; // Default 10 minutes

    public boolean kill = false;
    public Context context;

    Handler handler  = new Handler();

    Date nextNetworkReadTick;

    @Override
    public void run() {        
        Log.i("TST", "Start run() iteration");
        // Set the ticks to the appropriate values
        // Network gets read every 2 minutes …
Run Code Online (Sandbox Code Playgroud)

service gps android location

4
推荐指数
1
解决办法
2577
查看次数

标签 统计

android ×1

gps ×1

location ×1

service ×1