onLocationChanged not called on some devices

后端 未结 7 1501
悲哀的现实
悲哀的现实 2020-12-30 01:38

This is a question which has been asked numerous times but I could not find a solution that always works.

I am developing an application using the Fused location pro

7条回答
  •  轮回少年
    2020-12-30 02:14

    lr.setInterval(100); 
    

    with it your interval is 0,1 second so it very hard for gps chipset to detect location. Your interval should be > 1 second.(with me it is > 10)

    locationRequest it should be set:

    setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) because PRIORITY_BALANCED_POWER_ACCURACY in outdoor it doesn't get location . Code will look like :

    lr=LocationRequest.create();
    
    lr.setInterval(5 * 1000);// 5s
    
    lr.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationclient.requestLocationUpdates(lr, this);
    

    Hope this help.

提交回复
热议问题