本文整理汇总了Java中android.location.LocationManager.setTestProviderLocation方法的典型用法代码示例。如果您正苦于以下问题:Java LocationManager.setTestProviderLocation方法的具体用法?Java LocationManager.setTestProviderLocation怎么用?Java LocationManager.setTestProviderLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.location.LocationManager
的用法示例。
在下文中一共展示了LocationManager.setTestProviderLocation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scheduleMockGps
import android.location.LocationManager; //导入方法依赖的package包/类
private void scheduleMockGps(final Context context) {
Gps gps;
synchronized (mMockGps) {
gps = mMockGps[0];
}
if (null == gps) {
return;
}
if (!Macro.RealGps) {
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Location location = new Location(LocationManager.GPS_PROVIDER);
location.setLatitude(gps.mLatitude);
location.setLongitude(gps.mLongitude);
location.setAltitude(0);
location.setBearing(0);
location.setSpeed(0);
location.setAccuracy(2);
location.setTime(System.currentTimeMillis());
location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, location);
}
new Handler(context.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
scheduleMockGps(context);
}
}, 1000);
}