本文整理汇总了Java中com.nextgis.maplib.util.PermissionUtil类的典型用法代码示例。如果您正苦于以下问题:Java PermissionUtil类的具体用法?Java PermissionUtil怎么用?Java PermissionUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PermissionUtil类属于com.nextgis.maplib.util包,在下文中一共展示了PermissionUtil类的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 "";
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
示例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());
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}