本文整理匯總了Java中android.location.Criteria.setHorizontalAccuracy方法的典型用法代碼示例。如果您正苦於以下問題:Java Criteria.setHorizontalAccuracy方法的具體用法?Java Criteria.setHorizontalAccuracy怎麽用?Java Criteria.setHorizontalAccuracy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.location.Criteria
的用法示例。
在下文中一共展示了Criteria.setHorizontalAccuracy方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeCriteria
import android.location.Criteria; //導入方法依賴的package包/類
private void changeCriteria(Criteria criteria, int accuracy, int accuracyMinor, int power) {
criteria.setAccuracy(accuracy);
criteria.setHorizontalAccuracy(accuracyMinor);
criteria.setVerticalAccuracy(accuracyMinor);
criteria.setBearingAccuracy(accuracyMinor);
criteria.setSpeedAccuracy(accuracyMinor);
criteria.setPowerRequirement(power);
}
示例2: buildLocationSearchCriteria
import android.location.Criteria; //導入方法依賴的package包/類
private Criteria buildLocationSearchCriteria() {
Criteria expectedCriteria = new Criteria();
expectedCriteria.setCostAllowed(true);
expectedCriteria.setSpeedRequired(true);
expectedCriteria.setAltitudeRequired(false);
expectedCriteria.setBearingRequired(false);
expectedCriteria.setAccuracy(Criteria.ACCURACY_FINE);
expectedCriteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
expectedCriteria.setSpeedAccuracy(Criteria.ACCURACY_LOW);
expectedCriteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
expectedCriteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
return expectedCriteria;
}
示例3: getListener
import android.location.Criteria; //導入方法依賴的package包/類
private WLLocationListener getListener(JSONArray paramJSONArray, int paramInt1, int paramInt2, CallbackContext paramCallbackContext)
throws JSONException
{
boolean bool = paramJSONArray.getBoolean(paramInt1);
Criteria localCriteria = new Criteria();
int j;
int i;
String str1;
String str2;
if (bool)
{
j = paramJSONArray.getInt(paramInt2);
if (j < 100)
{
i = 3;
localCriteria.setHorizontalAccuracy(i);
str1 = this.locationManager.getBestProvider(localCriteria, true);
if (i != 3)
break label135;
str2 = "ACCURACY_HIGH";
}
}
while (true)
{
if (str1 != null)
break label155;
fail(WLLocationListener.PERMISSION_DENIED, "Android couldn't find a location provider for accuracy level " + str2 + " according to permissions in the Manifest and provider enablements in the device settings", paramCallbackContext, false);
return null;
if (j <= 500)
{
i = 2;
break;
}
i = 1;
break;
i = 1;
break;
label135: if (i == 2)
{
str2 = "ACCURACY_MEDIUM";
continue;
}
str2 = "ACCURACY_LOW";
}
label155: if (str1.equals("gps"))
return this.gpsListener;
if (i == 3)
Log.w("WL Geolocation Plugin", "Network provider selected for accuracy level " + str2 + ". Check the manifest for the ACCESS_FINE_LOCATION permission");
return this.networkListener;
}
示例4: handleMessage
import android.location.Criteria; //導入方法依賴的package包/類
@SuppressLint("NewApi")
public void handleMessage(Message msg) {
Log.i(TAG, "msg obj = " + String.valueOf(msg.obj));
switch(msg.what){
case MSG_GET_LOCATION:
Uri uri = Uri.parse(msg.obj.toString());
if(msg.getData() != null){
//Intent reply = msg.getData().getParcelable(Intent.EXTRA_INTENT);
PendingIntent replyTo = msg.getData().getParcelable(Intent.EXTRA_INTENT);
//Log.d(TAG, "replyTo: " + String.valueOf(replyTo));
LocationListener listener = getListener(null,uri,msg.arg1, msg.getData());
try{
Criteria criteria = new Criteria();
if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.FROYO){
criteria.setPowerRequirement(Criteria.POWER_HIGH);
criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
} else {
criteria.setAccuracy(Criteria.ACCURACY_FINE);
}
List<String> providers = locationManager.getProviders(criteria, true);
for(String provider: providers){
Log.d(TAG, "Using location provider: " + provider);
locationManager.requestLocationUpdates(provider, 0, 0, listener);
}
//if(TextUtils.isEmpty(provider))
// throw new IllegalArgumentException("No location providers available");
// add to our listeners so that we can clean up later if necessary
//replies.put(msg.arg1, replyTo);
if(providers.size() == 0){
Location nullLocation = new Location(LocationManager.GPS_PROVIDER);
nullLocation.setAccuracy(0);
nullLocation.setLatitude(0);
nullLocation.setLongitude(0);
listener.onLocationChanged(nullLocation);
} else {
listeners.put(msg.arg1, listener);
}
} catch (Exception e){
Log.e(TAG, "Error getting location updates: " + e.getMessage());
e.printStackTrace();
removeListener(msg.arg1);
}
} else {
Log.w(TAG, "no replyTo in original intent sent to InstrumentationService");
removeListener(msg.arg1);
}
break;
default:
Log.w(TAG, "Unknown message! Message = " + msg.what);
removeListener(msg.arg1);
}
}