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


Java PackageManager.PERMISSION_DENIED属性代码示例

本文整理汇总了Java中android.content.pm.PackageManager.PERMISSION_DENIED属性的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.PERMISSION_DENIED属性的具体用法?Java PackageManager.PERMISSION_DENIED怎么用?Java PackageManager.PERMISSION_DENIED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.pm.PackageManager的用法示例。


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

示例1: getPhoneIMEI

/**
 * 有做M上的权限兼容
 * @param context
 * @return
 */
public static String getPhoneIMEI(Context context) {
    String deviceID = "";
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int permissionResult = context.checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE);
        if (permissionResult == PackageManager.PERMISSION_DENIED) {
            permissionResult = context.checkCallingOrSelfPermission("android.permission.READ_PRIVILEGED_PHONE_STATE");
        }
        boolean isPermissionGranted = permissionResult == PackageManager.PERMISSION_GRANTED;
        if (!isPermissionGranted) {
            deviceID = getDeviceIDFromReflection(context);
        } else {
            deviceID = getDeviceIDFromSystem(context);
        }
    } else {
        deviceID = getDeviceIDFromSystem(context);
    }

    Log.i(TAG,"getPhoneIMEI : " + deviceID);
    return deviceID;
}
 
开发者ID:AnnyBaby,项目名称:Mvp-Retrofit-Rxjava-Rxbus,代码行数:25,代码来源:AppInfoUtils.java

示例2: onTransact

public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
        throws RemoteException {
    int check = checkCallingOrSelfPermission("com.ryg.chapter_2.permission.ACCESS_BOOK_SERVICE");
    Log.d(TAG, "check=" + check);
    if (check == PackageManager.PERMISSION_DENIED) {
        //return false;
    }

    String packageName = null;
    String[] packages = getPackageManager().getPackagesForUid(
            getCallingUid());
    if (packages != null && packages.length > 0) {
        packageName = packages[0];
    }
    Log.d(TAG, "onTransact: " + packageName);
    if (!packageName.startsWith("com.ryg")) {
        //return false;
    }

    return super.onTransact(code, data, reply, flags);
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:21,代码来源:BookManagerService.java

示例3: onRequestPermissionResult

public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) throws JSONException
{
    for(int r:grantResults)
    {
        if(r == PackageManager.PERMISSION_DENIED)
        {
            mCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }
    switch(requestCode)
    {
        case SAVE_SCREENSHOT_SEC:
            saveScreenshot();
            break;
        case SAVE_SCREENSHOT_URI_SEC:
            getScreenshotAsURI();
            break;
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:21,代码来源:Screenshot.java

示例4: onRequestPermissionsResult

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == AUDIO_PERMISSION_REQUEST && permissions[0]
            .equals(android.Manifest.permission.RECORD_AUDIO)) {
        if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                boolean showAgain =
                        shouldShowRequestPermissionRationale
                                (android.Manifest.permission.RECORD_AUDIO);
                if (showAgain) {

                }
            }
            finish(); // can't use audio
        }
    } else
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:18,代码来源:AudioActivity.java

示例5: onRequestPermissionResult

public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) /* throws JSONException */ {
    for(int result:grantResults) {
        if(result == PackageManager.PERMISSION_DENIED)
        {
            LOG.d(TAG, "User *rejected* Coarse Location Access");
            this.permissionCallback.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }

    switch(requestCode) {
        case REQUEST_ACCESS_COARSE_LOCATION:
            LOG.d(TAG, "User granted Coarse Location Access");
            findLowEnergyDevices(permissionCallback, serviceUUIDs, scanSeconds);
            this.permissionCallback = null;
            this.serviceUUIDs = null;
            this.scanSeconds = -1;
            break;
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:21,代码来源:BLECentralPlugin.java

示例6: writeExternalStoragePrmissionCheck

public void writeExternalStoragePrmissionCheck() {
    /* 사용자의 OS 버전이 마시멜로우 이상인지 체크한다. */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        /* 사용자 단말기의 권한 중 "저장소 쓰기" 권한이 허용되어 있는지 체크한다.
         */
        int permissionResult = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);

        /* WRITE_EXTERNAL_STORAGE의 권한이 없을 때 */
        if (permissionResult == PackageManager.PERMISSION_DENIED) {
            /* 사용자가 WRITE_EXTERNAL_STORAGE의 권한을 한번이라도 거부한 적이 있는 지 조사한다.
             * 거부한 이력이 한번이라도 있다면, true를 리턴한다.
             */
            requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_WRITE_STORAGE);
        }
    }
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-AndroidClient,代码行数:16,代码来源:MainActivity.java

示例7: hasInternetPermissions

public static void hasInternetPermissions(Context context, boolean shouldThrow) {
    Validate.notNull(context, "context");
    if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET) ==
            PackageManager.PERMISSION_DENIED) {
        if (shouldThrow) {
            throw new IllegalStateException(NO_INTERNET_PERMISSION_REASON);
        } else {
            Log.w(TAG, NO_INTERNET_PERMISSION_REASON);
        }
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:11,代码来源:Validate.java

示例8: connectToBluetooth

/**
 * connect to the bluetooth
 *
 * @param deviceInfo
 */
private void connectToBluetooth(final DeviceInfoBean deviceInfo) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            switch (ContextCompat.checkSelfPermission(getBaseContext(), Manifest.permission.ACCESS_COARSE_LOCATION)) {
                case PackageManager.PERMISSION_DENIED:
                    performPermissionDeniedAction(deviceInfo);
                    break;
                case PackageManager.PERMISSION_GRANTED:
                    startDeviceConnection(deviceInfo, healthCareReceiver);
                    break;
                default:
                    break;
            }
        } else {
            startDeviceConnection(deviceInfo, healthCareReceiver);
        }

    } catch (RuntimeException e) {
        showToastMessage(e.getMessage(), mContext);
        Log.e(AppUtility.TAG, Log.getStackTraceString(e));
    }

}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:28,代码来源:AllDeviceListActivity.java

示例9: onRequestPermissionResult

public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException {
  for (int r : grantResults) {
    if (r == PackageManager.PERMISSION_DENIED) {
      Log.d(LOG_TAG, "Permission Denied!");
      this.callback.error("Please allow access to the Calendar and try again.");
      return;
    }
  }

  // now call the originally requested actions
  if (requestCode == PERMISSION_REQCODE_CREATE_CALENDAR) {
    createCalendar(requestArgs);
  } else if (requestCode == PERMISSION_REQCODE_DELETE_CALENDAR) {
    deleteCalendar(requestArgs);
  } else if (requestCode == PERMISSION_REQCODE_CREATE_EVENT) {
    createEvent(requestArgs);
  } else if (requestCode == PERMISSION_REQCODE_DELETE_EVENT) {
    deleteEvent(requestArgs);
  } else if (requestCode == PERMISSION_REQCODE_FIND_EVENTS) {
    findEvents(requestArgs);
  } else if (requestCode == PERMISSION_REQCODE_LIST_CALENDARS) {
    listCalendars();
  } else if (requestCode == PERMISSION_REQCODE_LIST_EVENTS_IN_RANGE) {
    listEventsInRange(requestArgs);
  }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:26,代码来源:Calendar.java

示例10: onRequestPermissionResult

public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) throws JSONException {
    for (int r : grantResults) {
        if (r == PackageManager.PERMISSION_DENIED) {
            this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }
    switch (requestCode) {
        case TAKE_PIC_SEC:
            takePicture(this.destType, this.encodingType);
            break;
        case SAVE_TO_ALBUM_SEC:
            this.getImage(this.srcType, this.destType, this.encodingType);
            break;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:17,代码来源:CameraLauncher.java

示例11: onClick

@Override
public void onClick() {
	// request runtime permissions (Marshmallow+)
       if (Build.VERSION.SDK_INT >= 23) {
       	if ((getContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED)
       		|| (getContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED)) {
       		((Options)getContext()).requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
       		return;
       	} else {
       		super.onClick();
       	}
       } else {
       	super.onClick();
       }
}
 
开发者ID:HenriDellal,项目名称:emerald,代码行数:15,代码来源:BackupPreference.java

示例12: onMapReady

@Override
public void onMapReady(GoogleMap googleMap) {
    gMap = googleMap;
    gMap.setOnInfoWindowClickListener(this);
    if (ContextCompat.checkSelfPermission(getActivity(), permArr[0]) ==
            PackageManager.PERMISSION_DENIED)
        requestPermissions(permArr, LOCATION_PERM_REQUEST);
    else
        gMap.setMyLocationEnabled(true);
    mapReady = true;
    if (dataReady) refreshMarkers();
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:12,代码来源:TripMapFragment.java

示例13: onRequestPermissionsResult

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    for (int i = 0; i < grantResults.length; i++) {
        if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
            permissionResponse(requestCode, false);
            showPermissionWarn();
            return;
        }
    }
    permissionResponse(requestCode, true);
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:12,代码来源:BaseFragment.java

示例14: onRequestPermissionResult

public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) throws JSONException
{
    for(int r:grantResults)
    {
        if(r == PackageManager.PERMISSION_DENIED)
        {
            this.messageChannel.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }
    promptForRecord();
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:13,代码来源:AudioHandler.java

示例15: onRequestPermissionsResult

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    if (requestCode == REQUEST_PERMISSION) {
        // for each permission check if the user granted/denied them
        // you may want to group the rationale in a single dialog,
        // this is just an example
        int len = permissions.length;
        for (int i = 0; i < len; i++) {
            String permission = permissions[i];
            if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
                // user rejected the permission
                boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(RequestPermissionsActivity.this, permission );
                if (! showRationale) {
                    // user also CHECKED "never ask again"
                    // you can either enable some fall back,
                    // disable features of your app
                    // or open another dialog explaining
                    // again the permission and directing to
                    // the app setting

                } else if (Manifest.permission.WRITE_CONTACTS.equals(permission)) {
                    // todo define strings
                    showRationale(permission, R.string.permission_denied_contacts);
                    // user did NOT check "never ask again"
                    // this is a good place to explain the user
                    // why you need the permission and ask if he wants
                    // to accept it (the rationale)
                }
                //else if ( /* possibly check more permissions...*/ ) {}
            }
        }
    }
}
 
开发者ID:GregoireSailland,项目名称:AR,代码行数:33,代码来源:RequestPermissionsActivity.java


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