本文整理汇总了Java中io.nlopez.smartlocation.SmartLocation类的典型用法代码示例。如果您正苦于以下问题:Java SmartLocation类的具体用法?Java SmartLocation怎么用?Java SmartLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SmartLocation类属于io.nlopez.smartlocation包,在下文中一共展示了SmartLocation类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSending
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
private void initSending() {
//Log.d(TAG, "initSending()");
readSettings();
if (keywordReceivedSms) {
this.sendAcknowledgeMessage(phoneNumber);
}
//set bestLocation to null and start time
startTime = System.currentTimeMillis() / 1000;
bestLocation = null;
SmartLocation.with(context).location(new LocationGooglePlayServicesWithFallbackProvider(context))
.config(LocationParams.NAVIGATION)
.start(this);
}
示例2: getLocationState
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
@ReactMethod
public void getLocationState(Promise promise) {
LocationState locationState = SmartLocation.with(mReactContext).location().state();
WritableMap map = Arguments.createMap();
map.putBoolean("locationServicesEnabled", locationState.locationServicesEnabled());
map.putBoolean("isAnyProviderAvailable", locationState.isAnyProviderAvailable());
map.putBoolean("isGpsAvailable", locationState.isGpsAvailable());
map.putBoolean("isNetworkAvailable", locationState.isNetworkAvailable());
promise.resolve(map);
}
示例3: getLastLocation
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
private void getLastLocation() {
Location lastLocation = SmartLocation.with(getActivity()).location().getLastLocation();
if (lastLocation != null) {
latitude = lastLocation.getLatitude();
longitude = lastLocation.getLongitude();
}
}
示例4: initGps
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
private void initGps() {
LocationGooglePlayServicesProvider provider = new LocationGooglePlayServicesProvider(this);
provider.setCheckLocationSettings(true);
locationControl = new SmartLocation.Builder(this)
.logging(true)
.build()
.location(provider);
}
示例5: getAddressFromCoordinates
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
public static void getAddressFromCoordinates(Context context, Location location,
final OnGeoUtilResultListener onGeoUtilResultListener) {
SmartLocation.with(context).geocoding().reverse(location, (location1, list) -> {
String address = list.size() > 0 ? list.get(0).getAddressLine(0) : null;
onGeoUtilResultListener.onAddressResolved(address);
});
}
示例6: getCoordinatesFromAddress
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
public static void getCoordinatesFromAddress(Context context, String address, final OnGeoUtilResultListener
listener) {
SmartLocation.with(context).geocoding().direct(address, (name, results) -> {
if (results.size() > 0) {
listener.onCoordinatesResolved(results.get(0).getLocation(), address);
}
});
}
示例7: stopListeningForLocationUpdates
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
@ReactMethod
public void stopListeningForLocationUpdates() {
SmartLocation.with(mReactContext).location().stop();
}
示例8: onLocationUpdated
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
@Override
public void onLocationUpdated(Location location) {
//Log.d(TAG, "LOCATION UPDATE");
long currentTime = System.currentTimeMillis() / 1000;
//Log.d(TAG, "Start time: " + startTime + ", Current time: " + currentTime);
//Log.d(TAG, "Difference: " + (currentTime - startTime));
if (currentTime - startTime < this.LOCATION_REQUEST_MAX_WAIT_TIME) {
//Log.d(TAG, "NOT EXPIRED YET. CHECK");
if (bestLocation == null) {
bestLocation = location;
}
//still null? check again
if (bestLocation == null) {
//Log.d(TAG, "BEST LOCATION STILL NULL, CHECK MORE");
return;
}
//Log.d(TAG, bestLocation.toString());
//Log.d(TAG, location.toString());
//Log.d(TAG, "HAS ALTITUDE:" + location.hasAltitude());
//Log.d(TAG, "HAS SPEED: " + location.hasSpeed());
//Log.d(TAG, "LOCATION PROVIDER: " + location.getProvider());
if (!bestLocation.getProvider().equals(LocationManager.GPS_PROVIDER) || bestLocation.getProvider().equals(location.getProvider())) {
//Log.d(TAG, "NOT GPS OR BOTH GPS!");
if (location.getAccuracy() < bestLocation.getAccuracy()) {
//Log.d(TAG, "Update best location.");
bestLocation = location;
}
}
if (this.isLocationFused(bestLocation)) {
//Log.d(TAG, "Location still fused.");
return;
}
if (bestLocation.getAccuracy() > 100) {
//Log.d(TAG, "Accuracy more than 100, check again.");
return;
}
}
//stop the location
//Log.d(TAG, "STOP LOCATION BECAUSE TIME ELAPSED OR ACCURACY IS GOOD");
SmartLocation.with(context).location().stop();
if (bestLocation == null) {
this.sendSMS(phoneNumber, r.getString(R.string.error_getting_location));
return;
}
if (gpsSms) {
this.sendLocationMessage(phoneNumber, bestLocation);
}
if (googleMapsSms) {
this.sendGoogleMapsMessage(phoneNumber, bestLocation);
}
if (!networkSms) {
return;
}
this.sendNetworkMessage(phoneNumber, bestLocation, place, new OnNetworkMessageSentListener() {
@Override
public void onNetworkMessageSent() {
//Log.d(TAG, "on Network Message Sent");
}
});
}
示例9: onDestroy
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
@Override
protected void onDestroy() {
super.onDestroy();
SmartLocation.with(ChooseBranchActivity.this).location().stop();
}
示例10: initGps
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
private void initGps() {
locationControl = new SmartLocation.Builder(this)
.logging(true)
.build()
.location(new LocationGooglePlayServicesWithFallbackProvider(this));
}
示例11: getLocation
import io.nlopez.smartlocation.SmartLocation; //导入依赖的package包/类
public static void getLocation(Context context, OnGeoUtilResultListener onGeoUtilResultListener) {
SmartLocation.with(context).location().config(LocationParams.NAVIGATION).provider(new
LocationGooglePlayServicesWithFallbackProvider(context)).oneFix().start
(onGeoUtilResultListener::onLocationRetrieved);
}