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


Java PermissionUtil.hasPermission方法代码示例

本文整理汇总了Java中com.nextgis.maplib.util.PermissionUtil.hasPermission方法的典型用法代码示例。如果您正苦于以下问题:Java PermissionUtil.hasPermission方法的具体用法?Java PermissionUtil.hasPermission怎么用?Java PermissionUtil.hasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.nextgis.maplib.util.PermissionUtil的用法示例。


在下文中一共展示了PermissionUtil.hasPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAccountPassword

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public String getAccountPassword(Account account)
{
    if(!PermissionUtil.hasPermission(this, ConstantsUI.PERMISSION_AUTHENTICATE_ACCOUNTS)){
        return "";
    }

    if (!isAccountManagerValid())
        return "";

    try {
        return mAccountManager.getPassword(account);
    } catch (SecurityException e) {
        e.printStackTrace();
        return "";
    }
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:18,代码来源:GISApplication.java

示例2: addListener

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
/**
 * Add new listener for GPS events. You will likely want to call addListener() from your
 * Activity's or Fragment's onResume() method, to enable the features. Remember to call the
 * corresponding removeListener() in your Activity's or Fragment's onPause() method, to prevent
 * unnecessary use of the battery.
 *
 * @param listener
 *         A listener class implements GpsEventListener adding to listeners array
 */
public void addListener(GpsEventListener listener)
{
    if (mListeners != null && !mListeners.contains(listener)) {
        mListeners.add(listener);

        if (mListeners.size() == 1) {
            if(!PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)
                || !PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION))
                return;

            requestUpdates();
            mLocationManager.addGpsStatusListener(mGpsStatusListener);
        }
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:25,代码来源:GpsEventSource.java

示例3: removeListener

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
/**
 * Remove listener from listeners of GPS events. You will likely want to call removeListener()
 * from your Activity's or Fragment's onPause() method, to prevent unnecessary use of the
 * battery. Remember to call the corresponding addListener() in your Activity's or Fragment's
 * onResume() method.
 *
 * @param listener
 *         A listener class implements GpsEventListener removing from listeners array
 */
public void removeListener(GpsEventListener listener)
{
    if (mListeners != null) {
        mListeners.remove(listener);

        if(!PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)
                || !PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION))
            return;

        if (mListeners.size() == 0) {
            mLocationManager.removeUpdates(mGpsLocationListener);
            mLocationManager.removeGpsStatusListener(mGpsStatusListener);
        }
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:25,代码来源:GpsEventSource.java

示例4: updateActiveListeners

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
public void updateActiveListeners()
{
    SharedPreferences sharedPreferences =
            PreferenceManager.getDefaultSharedPreferences(mContext);
    mListenProviders = Integer.parseInt(sharedPreferences.getString(
            SettingsConstants.KEY_PREF_LOCATION_SOURCE, "3"));

    String minTimeStr =
            sharedPreferences.getString(SettingsConstants.KEY_PREF_LOCATION_MIN_TIME, "2");
    String minDistanceStr =
            sharedPreferences.getString(SettingsConstants.KEY_PREF_LOCATION_MIN_DISTANCE, "10");
    mUpdateMinTime = Long.parseLong(minTimeStr) * 1000;
    mUpdateMinDistance = Float.parseFloat(minDistanceStr);

    if(!PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)
            || !PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION))
        return;

    mLocationManager.removeUpdates(mGpsLocationListener);
    if (mListeners.size() >= 1)
        requestUpdates();
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:23,代码来源:GpsEventSource.java

示例5: stopTaking

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
public void stopTaking()
{
    mIsStopped = true;

    mHandler.removeCallbacks(mStopTakingRunner);
    mHandler.removeCallbacks(mProgressUpdateRunner);

    if (null != mGpsTakings && !isCancelled() && null != mOnGetAccurateLocationListener) {
        Log.d(Constants.TAG, "Get the GPS accurate location");
        mOnGetAccurateLocationListener.onGetAccurateLocation(
                getAccurateLocation(mCircularError), (long) mGpsTakings.size(),
                mTakeTimeMillis);
    }

    if(!PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)
            || !PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION))
        return;

    if (null != mLocationManager) {
        mLocationManager.removeUpdates(this);
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:23,代码来源:AccurateLocationTaker.java

示例6: onCreate

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (null == getParentFragment()) {
        setRetainInstance(true);
    }

    // reference to vibrator service
    mDeclination = 0;
    mVibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);

    if(!PermissionUtil.hasPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)
            || !PermissionUtil.hasPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION))
        return;

    if (mCurrentLocation == null) {
        LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
        mCurrentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

        if (mCurrentLocation == null) {
            mCurrentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }
    }

    if (mCurrentLocation != null)
        mDeclination = getDeclination(mCurrentLocation, System.currentTimeMillis());
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:30,代码来源:CompassFragment.java

示例7: getAccount

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public Account getAccount(String accountName)
{
    if(!PermissionUtil.hasPermission(this, Manifest.permission.GET_ACCOUNTS)){
        return null;
    }

    if (!isAccountManagerValid()) {
        return null;
    }
    try {
        for (Account account : mAccountManager.getAccountsByType(getAccountsType())) {
            if (account == null) {
                continue;
            }
            if(Constants.DEBUG_MODE)
                Log.d(Constants.TAG, "getAccount check account: " + account.toString());
            if (account.name.equals(accountName)) {
                return account;
            }
        }
    }
    catch (SecurityException e){
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:28,代码来源:GISApplication.java

示例8: addAccount

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public boolean addAccount(String name, String url, String login, String password, String token) {
    if(!PermissionUtil.hasPermission(this, ConstantsUI.PERMISSION_AUTHENTICATE_ACCOUNTS)){
        return false;
    }

    if (!isAccountManagerValid() || TextUtils.isEmpty(url))
        return false;

    final Account account = new Account(name, getAccountsType());

    Bundle userData = new Bundle();
    userData.putString("url", url.trim());
    userData.putString("login", login);

    try {
        boolean accountAdded = mAccountManager.addAccountExplicitly(account, password, userData);
        if (accountAdded)
            mAccountManager.setAuthToken(account, account.type, token);

        return accountAdded;
    }
    catch (SecurityException e){
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:28,代码来源:GISApplication.java

示例9: setPassword

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public void setPassword(String name, String value) {
    if(!PermissionUtil.hasPermission(this, ConstantsUI.PERMISSION_AUTHENTICATE_ACCOUNTS)){
        return;
    }

    Account account = getAccount(name);
    if (null != account) {
        mAccountManager.setPassword(account, value);
    }
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:12,代码来源:GISApplication.java

示例10: setUserData

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public void setUserData(String name, String key, String value) {
    if(!PermissionUtil.hasPermission(this, ConstantsUI.PERMISSION_AUTHENTICATE_ACCOUNTS)){
        return;
    }

    Account account = getAccount(name);
    if (null != account) {
        mAccountManager.setUserData(account, key, value);
    }
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:12,代码来源:GISApplication.java

示例11: getAccountUserData

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public String getAccountUserData(Account account, String key) {
    if(!PermissionUtil.hasPermission(this, ConstantsUI.PERMISSION_AUTHENTICATE_ACCOUNTS)){
        return "";
    }

    if (!isAccountManagerValid())
        return "";

    String result =  null;
    if (account != null)
        result = mAccountManager.getUserData(account, key);
    return result == null ? "" : result;
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:15,代码来源:GISApplication.java

示例12: onDestroy

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
public void onDestroy()
{
    stopTrack();
    removeNotification();
    stopSelf();

    if(PermissionUtil.hasPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
            && PermissionUtil.hasPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
        mLocationManager.removeUpdates(this);
        mLocationManager.removeGpsStatusListener(this);
    }

    super.onDestroy();
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:15,代码来源:TrackerService.java

示例13: startWalkEdit

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
private void startWalkEdit() {
    SharedPreferences sharedPreferences = getSharedPreferences(getPackageName() + "_preferences", Constants.MODE_MULTI_PROCESS);

    String minTimeStr = sharedPreferences.getString(SettingsConstants.KEY_PREF_LOCATION_MIN_TIME, "2");
    String minDistanceStr = sharedPreferences.getString(SettingsConstants.KEY_PREF_LOCATION_MIN_DISTANCE, "10");
    long minTime = Long.parseLong(minTimeStr) * 1000;
    float minDistance = Float.parseFloat(minDistanceStr);

    if (!PermissionUtil.hasPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) || !PermissionUtil
            .hasPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION))
        return;

    mLocationManager.addGpsStatusListener(this);

    String provider = LocationManager.GPS_PROVIDER;
    if (mLocationManager.getAllProviders().contains(provider)) {
        mLocationManager.requestLocationUpdates(provider, minTime, minDistance, this);
    }

    provider = LocationManager.NETWORK_PROVIDER;
    if (mLocationManager.getAllProviders().contains(provider)) {
        mLocationManager.requestLocationUpdates(provider, minTime, minDistance, this);
    }

    NotificationHelper.showLocationInfo(this);
    initTargetIntent(mTargetActivity);
    addNotification();
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:29,代码来源:WalkEditService.java

示例14: onDestroy

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
@Override
public void onDestroy() {
    mSharedPreferencesTemp.edit().clear().commit();
    removeNotification();
    stopSelf();

    if (PermissionUtil.hasPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) && PermissionUtil
            .hasPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
        mLocationManager.removeUpdates(this);
        mLocationManager.removeGpsStatusListener(this);
    }

    super.onDestroy();
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:15,代码来源:WalkEditService.java

示例15: getLastKnownLocation

import com.nextgis.maplib.util.PermissionUtil; //导入方法依赖的package包/类
public Location getLastKnownLocation()
{
    if(!PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)
            || !PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION))
        return null;

    if (null != mLastLocation) {
        return mLastLocation;
    }

    if (null != mLocationManager) {
        if (0 != (mListenProviders & GPS_PROVIDER)) {
            mLastLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            if (null != mLastLocation) {
                return mLastLocation;
            }
        }

        if (0 != (mListenProviders & NETWORK_PROVIDER)) {
            mLastLocation =
                    mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            if (null != mLastLocation) {
                return mLastLocation;
            }
        }
    }
    return null;
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:29,代码来源:GpsEventSource.java


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