當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。