GPS not update location after close and reopen app on android

后端 未结 2 1359
清歌不尽
清歌不尽 2020-12-01 12:03

After I closed my app for a while then reopen it again,my app will not update location or sometime it will take long time( about 5min) before update. How can I fix it? This

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 12:07

    first thing why u have used 0 mintime and 0 precision it will drain your battery very fast..avoid this if its not necessity
    secondly the time lag u mentioned here is definitely the time taken by the gps chip to access the gps data which can vary sometimes depending on GPS signal availability
    and regarding update u should try this

    public void onLocationChanged(Location loc) {
            if (loc != null) {
                TextView gpsloc = (TextView) findViewById(R.id.widget28);
                gpsloc.setText("Lat:"+loc.getLatitude()+" Lng:"+ loc.getLongitude());
            }
            else
                 {gpsloc.setText("provider not available");}//provider available or not 
    
        }
    

    there might be a chance that there is no provider available to update the location

提交回复
热议问题