当前位置: 首页>>代码示例>>Java>>正文


Java LocationManager.getProvider方法代码示例

本文整理汇总了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();
}
 
开发者ID:wade-fs,项目名称:Military-North-Compass,代码行数:26,代码来源:TriangleView.java

示例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();
}
 
开发者ID:wade-fs,项目名称:Military-North-Compass,代码行数:29,代码来源:Compass.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:62,代码来源:LocationUtils.java


注:本文中的android.location.LocationManager.getProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。