本文整理汇总了Java中android.location.LocationManager.getProvider方法的典型用法代码示例。如果您正苦于以下问题:Java LocationManager.getProvider方法的具体用法?Java LocationManager.getProvider怎么用?Java LocationManager.getProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.location.LocationManager
的用法示例。
在下文中一共展示了LocationManager.getProvider方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TriangleView
import android.location.LocationManager; //导入方法依赖的package包/类
public TriangleView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mainActivity = (GraphicActivity)context;
mainActivity.A = new PointF(0, 0);
mainActivity.B = new PointF(100, 0);
mainActivity.distance = Tools.len(mainActivity.A.x-mainActivity.B.x, mainActivity.A.y-mainActivity.B.y);
double r = mainActivity.distance*Math.sin(mainActivity.angleB) / (Math.sin(mainActivity.angleA - mainActivity.angleB));
mainActivity.P = new PointF((float)(-r * Math.cos(mainActivity.angleA)+mainActivity.A.x),
(float)( r * Math.sin(mainActivity.angleA)+mainActivity.A.y));
mainActivity.angleA = 120*Math.PI/180;
mainActivity.angleB = 60*Math.PI/180;
initialisePaint();
mLocationManager = (LocationManager) mainActivity.getSystemService(Context.LOCATION_SERVICE);
mProvider = mLocationManager.getProvider(LocationManager.GPS_PROVIDER);
if (mProvider == null) {
warn("未支援 GPS", 0);
mainActivity.finish();
return;
}
mProj = new Proj();
restore();
}
示例2: Compass
import android.location.LocationManager; //导入方法依赖的package包/类
Compass(Context context) {
mainActivity = (CompassActivity) context;
mSensorManager = (SensorManager) mainActivity.getSystemService(Context.SENSOR_SERVICE);
mLocationManager = (LocationManager) mainActivity.getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
{
warn("請檢查本應用程式是否授權使用『位置』及『儲存』", 0);
mainActivity.finish();
return;
}
mProvider = mLocationManager.getProvider(LocationManager.GPS_PROVIDER);
if (mProvider == null) {
warn("未支援 GPS", 0);
mainActivity.finish();
return;
}
minTime = (long) (SECONDS_TO_MILLISECONDS);
minDistance = 0;
gSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
oSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
rSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
mProj = new Proj();
cpdb = new CPDB(context);
restore();
}
示例3: getProvider
import android.location.LocationManager; //导入方法依赖的package包/类
public static String getProvider(Context ctx, LocationManager mLocationManager) {
String mProviderName = "";
if (isNetworkConnected(ctx)) {
boolean hasGpsProvide;
boolean hasNetWorkProvider;
if (mLocationManager.getProvider("gps") != null) {
hasGpsProvide = true;
} else {
hasGpsProvide = false;
}
if (mLocationManager.getProvider("network") != null) {
hasNetWorkProvider = true;
} else {
hasNetWorkProvider = false;
}
Helper.showLog(TAG, " hasGpsProvide =" + hasGpsProvide + " hasNetWorkProvider =" +
hasNetWorkProvider);
boolean isGpsEnabled = isGPSProviderAvaliable(ctx);
boolean isWIFIEnabled = isWIFIProviderAvaliable(ctx);
if (!hasGpsProvide && !hasNetWorkProvider) {
Helper.showToast(ctx, (int) R.string.xw);
return ctx.getString(R.string.xw);
} else if (!hasGpsProvide && hasNetWorkProvider) {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>only network provider");
if (isWIFIEnabled) {
mProviderName = "network";
} else {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>no network avaliable");
return null;
}
} else if (!hasGpsProvide || hasNetWorkProvider) {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>hasallprovider");
if (!isGpsEnabled && !isWIFIEnabled) {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>no GPS or NETWORK avaliable");
return null;
} else if (isGpsEnabled && !isWIFIEnabled) {
mProviderName = "gps";
} else if (!isGpsEnabled && isWIFIEnabled) {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>network avaliable");
mProviderName = "network";
} else if (isGpsEnabled && isWIFIEnabled) {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>all avaliable");
mProviderName = "gps";
if (mLocationManager.getLastKnownLocation("gps") == null) {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>all avaliable but location is null");
mProviderName = "network";
}
}
} else {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>only GPS provider");
if (isGpsEnabled) {
mProviderName = "gps";
} else {
Helper.showLog(TAG, ">>>>>>>>>>>>>>>no GPS avaliable");
return null;
}
}
}
Helper.showToast(ctx, ctx.getString(R.string.gu));
return mProviderName;
}