Mock GPS location issue

后端 未结 1 1384
抹茶落季
抹茶落季 2021-01-06 17:11

I\'m developing an APP that get user specified latitude,longitude, and altitude, then fake this GPS location on the phone, and show that I am at that location in google map.

1条回答
  •  -上瘾入骨i
    2021-01-06 17:54

    Problem solved: I added the following code to set my current location and it can successfully show up in google map application.

    location.setLatitude(latitude);
    location.setLongitude(longitude);
    location.setBearing(bearing);
    location.setSpeed(speed);
    location.setAltitude(altitude);
    location.setTime(new Date().getTime());
    location.setProvider(LocationManager.GPS_PROVIDER);
    location.setAccuracy(1);
    

    Conclusion: If you want to use mock location service in the new version of android, you have to set every attribute by yourself.

    0 讨论(0)
提交回复
热议问题