java类android.support.annotation.RequiresPermission的实例源码

BluetoothPlugin.java 文件源码 项目:UnityBluetoothPlugin 阅读 34 收藏 0 点赞 0 评论 0
@RequiresPermission("android.permission.BLUETOOTH")
public String SetupPlugin() {
    // Bluetooth Adapter
    this.mBtAdapter = BluetoothAdapter.getDefaultAdapter();

    // if Bluettoth Adapter is avaibale, start Service
    if(this.mBtAdapter == null) {
        return "Bluetooth is not available";

    } else {
        if(this.mBtService == null) {
            this.startService();
        }

        return "SUCCESS";
    }
}
CameraSourcePreview.java 文件源码 项目:AndroidOCRFforID 阅读 42 收藏 0 点赞 0 评论 0
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
    if (mStartRequested && mSurfaceAvailable) {
        mCameraSource.start(mSurfaceView.getHolder());
        if (mOverlay != null) {
            Size size = mCameraSource.getPreviewSize();
            int min = Math.min(size.getWidth(), size.getHeight());
            int max = Math.max(size.getWidth(), size.getHeight());
            if (isPortraitMode()) {
                // Swap width and height sizes when in portrait, since it will be rotated by
                // 90 degrees
                mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
            } else {
                mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
            }
            mOverlay.clear();
        }
        mStartRequested = false;
    }
}
CameraSource.java 文件源码 项目:SocialPaka 阅读 41 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The supplied
 * surface holder is used for the preview so frames can be displayed to the user.
 *
 * @param surfaceHolder the surface holder to use for the preview frames
 * @throws IOException if the supplied surface holder could not be used as the preview display
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start(SurfaceHolder surfaceHolder) throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();
        mCamera.setPreviewDisplay(surfaceHolder);
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
CameraSourcePreview.java 文件源码 项目:Barcode-Reader 阅读 42 收藏 0 点赞 0 评论 0
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
    if (mStartRequested && mSurfaceAvailable) {
        mCameraSource.start(mSurfaceView.getHolder());
        if (mOverlay != null) {
            Size size = mCameraSource.getPreviewSize();
            int min = Math.min(size.getWidth(), size.getHeight());
            int max = Math.max(size.getWidth(), size.getHeight());
            if (isPortraitMode()) {
                // Swap width and height sizes when in portrait, since it will be rotated by
                // 90 degrees
                mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
            } else {
                mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
            }
            mOverlay.clear();
        }
        mStartRequested = false;
    }
}
ConcealPrefRepository.java 文件源码 项目:ConcealSharedPreference-Android 阅读 32 收藏 0 点赞 0 评论 0
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
public File putFile(@NonNull String key, @Nullable File file,boolean deleteOldFile){

    if (file == null)
        return null;

    try {
        if (file.exists() && !FileUtils.isFileForImage(file)) {
            File enc = concealCrypto.obscureFile(file,deleteOldFile);
            putString(key, enc.getAbsolutePath());
            return enc;
        }
    }
    catch (Exception e){
        e.printStackTrace();
    }

    return null;
}
CameraSourcePreview.java 文件源码 项目:Fuse 阅读 44 收藏 0 点赞 0 评论 0
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
    if (mStartRequested && mSurfaceAvailable) {
        mCameraSource.start(mSurfaceView.getHolder());
        if (mOverlay != null) {
            Size size = mCameraSource.getPreviewSize();
            int min = Math.min(size.getWidth(), size.getHeight());
            int max = Math.max(size.getWidth(), size.getHeight());
            if (isPortraitMode()) {
                // Swap width and height sizes when in portrait, since it will be rotated by
                // 90 degrees
                mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
            } else {
                mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
            }
            mOverlay.clear();
        }
        mStartRequested = false;
    }
}
CameraSource.java 文件源码 项目:Barcode-Reader 阅读 53 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The supplied
 * surface holder is used for the preview so frames can be displayed to the user.
 *
 * @param surfaceHolder the surface holder to use for the preview frames
 * @throws IOException if the supplied surface holder could not be used as the preview display
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start(SurfaceHolder surfaceHolder) throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();
        mCamera.setPreviewDisplay(surfaceHolder);
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
CameraSource.java 文件源码 项目:Toodoo 阅读 44 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The supplied
 * surface holder is used for the preview so frames can be displayed to the user.
 *
 * @param surfaceHolder the surface holder to use for the preview frames
 * @throws IOException if the supplied surface holder could not be used as the preview display
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start(SurfaceHolder surfaceHolder) throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();
        mCamera.setPreviewDisplay(surfaceHolder);
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
CameraSourcePreview.java 文件源码 项目:BuddyBook 阅读 41 收藏 0 点赞 0 评论 0
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
    if (mStartRequested && mSurfaceAvailable) {
        mCameraSource.start(mSurfaceView.getHolder());
        if (mOverlay != null) {
            Size size = mCameraSource.getPreviewSize();
            int min = Math.min(size.getWidth(), size.getHeight());
            int max = Math.max(size.getWidth(), size.getHeight());
            if (isPortraitMode()) {
                // Swap width and height sizes when in portrait, since it will be rotated by
                // 90 degrees
                mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
            } else {
                mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
            }
            mOverlay.clear();
        }
        mStartRequested = false;
    }
}
CameraSource.java 文件源码 项目:BuddyBook 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The supplied
 * surface holder is used for the preview so frames can be displayed to the user.
 *
 * @param surfaceHolder the surface holder to use for the preview frames
 * @throws IOException if the supplied surface holder could not be used as the preview display
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start(SurfaceHolder surfaceHolder) throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();
        mCamera.setPreviewDisplay(surfaceHolder);
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
LocationService.java 文件源码 项目:Android-Location-Tracker 阅读 46 收藏 0 点赞 0 评论 0
@RequiresPermission(allOf = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
public void removeLocationUpdates() {
    if (Configuration.sIsFeatureLocationAvailable) {
        LogHelper.debugLog(TAG, "Removing location updates...");
        try {
            mLocationManager.removeUpdates(this);

            mIsRequestingLocationUpdates = false;
        } catch (SecurityException e) {
            LogHelper.errorLog(TAG, "Error while trying to remove location updates; " + e.getMessage());
            e.printStackTrace();
        }
    } else {
        LogHelper.warnLog(TAG, "Will not remove location updates, location feature is not available");
    }
}
CameraSource.java 文件源码 项目:trust-wallet-android 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The supplied
 * surface holder is used for the preview so frames can be displayed to the user.
 *
 * @param surfaceHolder the surface holder to use for the preview frames
 * @throws IOException if the supplied surface holder could not be used as the preview display
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start(SurfaceHolder surfaceHolder) throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();
        mCamera.setPreviewDisplay(surfaceHolder);
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
Camera2Source.java 文件源码 项目:Camera2Vision 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The supplied
 * texture view is used for the preview so frames can be displayed to the user.
 *
 * @param textureView the surface holder to use for the preview frames
 * @param displayOrientation the display orientation for a non stretched preview
 * @throws IOException if the supplied texture view could not be used as the preview display
 */
@RequiresPermission(Manifest.permission.CAMERA)
public Camera2Source start(@NonNull AutoFitTextureView textureView, int displayOrientation) throws IOException {
    mDisplayOrientation = displayOrientation;
    if(ContextCompat.checkSelfPermission(mContext, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
        if (cameraStarted) {
            return this;
        }
        cameraStarted = true;
        startBackgroundThread();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();

        mTextureView = textureView;
        if (mTextureView.isAvailable()) {
            setUpCameraOutputs(mTextureView.getWidth(), mTextureView.getHeight());
        }
    }
    return this;
}
BigImageView.java 文件源码 项目:garras 阅读 35 收藏 0 点赞 0 评论 0
@RequiresPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
public void saveImageIntoGallery() {
    if (mCurrentImageFile == null) {
        if (mImageSaveCallback != null) {
            mImageSaveCallback.onFail(new IllegalStateException("image not downloaded yet"));
        }

        return;
    }

    try {
        String result = MediaStore.Images.Media.insertImage(getContext().getContentResolver(),
                mCurrentImageFile.getAbsolutePath(), mCurrentImageFile.getName(), "");
        if (mImageSaveCallback != null) {
            if (!TextUtils.isEmpty(result)) {
                mImageSaveCallback.onSuccess(result);
            } else {
                mImageSaveCallback.onFail(new RuntimeException("saveImageIntoGallery fail"));
            }
        }
    } catch (FileNotFoundException e) {
        if (mImageSaveCallback != null) {
            mImageSaveCallback.onFail(e);
        }
    }
}
LocationLayerPlugin.java 文件源码 项目:mapbox-plugins-android 阅读 40 收藏 0 点赞 0 评论 0
/**
 * Required to place inside your activities {@code onStart} method. You'll also most likely want
 * to check that this Location Layer plugin instance inside your activity is null or not.
 *
 * @since 0.1.0
 */
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
  if (locationLayerMode != LocationLayerMode.NONE) {
    setLocationLayerEnabled(locationLayerMode);
  }

  if (!compassManager.getCompassListeners().isEmpty()
    || (locationLayerMode == LocationLayerMode.COMPASS && compassManager.isSensorAvailable())) {
    compassManager.onStart();
  }
  if (mapboxMap != null) {
    mapboxMap.addOnCameraMoveListener(this);
  }
}
BluetoothPlugin.java 文件源码 项目:UnityBluetoothPlugin 阅读 41 收藏 0 点赞 0 评论 0
@RequiresPermission(
        allOf = {"android.permission.BLUETOOTH", "android.permission.BLUETOOTH_ADMIN"}
)
String DisableBluetooth() {
    if(!this.mBtAdapter.isEnabled()) {
        return "You Must Enable The BlueTooth";
    } else {
        if(this.mBtAdapter != null) {
            this.mBtAdapter.cancelDiscovery();
        }

        if(this.mBtAdapter.isEnabled()) {
            this.mBtAdapter.disable();
        }

        return "SUCCESS";
    }
}
BluetoothPlugin.java 文件源码 项目:UnityBluetoothPlugin 阅读 39 收藏 0 点赞 0 评论 0
@RequiresPermission("android.permission.BLUETOOTH")
public void stopThread() {
    Log.d(TAG, "stop");
    if(this.mBtService != null) {
        this.mBtService.stop();
        this.mBtService = null;
    }

    if(this.mBtAdapter != null) {
        this.mBtAdapter = null;
    }

    this.SetupPlugin();
}
RxLocationManager.java 文件源码 项目:smart-asset-iot-android-demo 阅读 38 收藏 0 点赞 0 评论 0
@SuppressWarnings("MissingPermission")
@RequiresPermission(anyOf = {
        Manifest.permission.ACCESS_COARSE_LOCATION,
        Manifest.permission.ACCESS_FINE_LOCATION
})
private Observable<Location> lastLocation() {
    return rxLocation.location().lastLocation().toObservable()
            .doOnSubscribe(ignore -> Timber.d("lastLocation: on subscribe"))
            .doOnNext(item -> Timber.d("lastLocation: item: " + item))
            .doOnComplete(() -> Timber.d("lastLocation: on complete"))
            .doOnDispose(() -> Timber.d("lastLocation: on dispose"));
}
RxLocationManager.java 文件源码 项目:smart-asset-iot-android-demo 阅读 55 收藏 0 点赞 0 评论 0
@SuppressWarnings("MissingPermission")
@RequiresPermission(anyOf = {
        Manifest.permission.ACCESS_COARSE_LOCATION,
        Manifest.permission.ACCESS_FINE_LOCATION
})
private Observable<Location> locationUpdates() {
    return rxLocation.location().updates(locationRequest)
            .subscribeOn(Schedulers.io())
            .doOnSubscribe(ignore -> Timber.d("locationUpdates: on subscribe"))
            .doOnNext(item -> Timber.d("locationUpdates: item: " + item))
            .doOnComplete(() -> Timber.d("locationUpdates: on complete"))
            .doOnDispose(() -> Timber.d("locationUpdates: on dispose"));
}
CameraSource.java 文件源码 项目:Toodoo 阅读 66 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The preview
 * frames are not displayed.
 *
 * @throws IOException if the camera's preview texture or display could not be initialized
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();

        // SurfaceTexture was introduced in Honeycomb (11), so if we are running and
        // old version of Android. fall back to use SurfaceView.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
            mCamera.setPreviewTexture(mDummySurfaceTexture);
        } else {
            mDummySurfaceView = new SurfaceView(mContext);
            mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
        }
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
ConcealPrefRepository.java 文件源码 项目:ConcealSharedPreference-Android 阅读 39 收藏 0 点赞 0 评论 0
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
public String putImage(@NonNull String key, Bitmap bitmap){
    File imageFile = new File(getImageDirectory(mFolderName),"images_"+System.currentTimeMillis()+".png");
    if(FileUtils.saveBitmap(imageFile, bitmap)){
        concealCrypto.obscureFile(imageFile,true);
        editor.putString(key,imageFile.getAbsolutePath()).apply();
        return imageFile.getAbsolutePath();
    }
    return null;
}
ConcealPrefRepository.java 文件源码 项目:ConcealSharedPreference-Android 阅读 34 收藏 0 点赞 0 评论 0
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
public String putImage(@NonNull String key, @Nullable File file){
    if (FileUtils.isFileForImage(file)) {
        File imageFile = FileUtils.moveFile(file,getImageDirectory(mFolderName));
        if (imageFile!=null && imageFile.exists()) {
            concealCrypto.obscureFile(imageFile,true);
            putString(key, imageFile.getAbsolutePath());
            return imageFile.getAbsolutePath();
        }
    }
    return null;
}
BluetoothJellyBean.java 文件源码 项目:BluetoothKit 阅读 34 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
@RequiresPermission(allOf = {Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.BLUETOOTH})
@Override
public void startScanInternal() {
    if(!isScanning){
        this.callBack = getCallBack();
        bluetoothAdapter.startLeScan(this);

        isScanning = true;
    }
}
BluetoothJellyBean.java 文件源码 项目:BluetoothKit 阅读 32 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
@RequiresPermission(allOf = {Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.BLUETOOTH})
@Override
public void stopScanInternal() {
    if(isScanning){
        bluetoothAdapter.stopLeScan(this);

        isScanning = false;
    }
}
BluetoothPlugin.java 文件源码 项目:UnityBluetoothPlugin 阅读 37 收藏 0 点赞 0 评论 0
@RequiresPermission("android.permission.BLUETOOTH")
public synchronized void onResume() {
    super.onResume();
    Log.d(TAG, "+ ON RESUME +");
    if(this.mBtService != null && this.mBtService.getState() == 0) {
        this.mBtService.start();
    }

}
CameraSource.java 文件源码 项目:Fuse 阅读 40 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The preview
 * frames are not displayed.
 *
 * @throws IOException if the camera's preview texture or display could not be initialized
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();

        // SurfaceTexture was introduced in Honeycomb (11), so if we are running and
        // old version of Android. fall back to use SurfaceView.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
            mCamera.setPreviewTexture(mDummySurfaceTexture);
        } else {
            mDummySurfaceView = new SurfaceView(mContext);
            mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
        }
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
CameraSourcePreview.java 文件源码 项目:AndroidOCRFforID 阅读 38 收藏 0 点赞 0 评论 0
@RequiresPermission(Manifest.permission.CAMERA)
public void start(CameraSource cameraSource) throws IOException, SecurityException {
    if (cameraSource == null) {
        stop();
    }

    mCameraSource = cameraSource;

    if (mCameraSource != null) {
        mStartRequested = true;
        startIfReady();
    }
}
CameraSource.java 文件源码 项目:trust-wallet-android 阅读 49 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The preview
 * frames are not displayed.
 *
 * @throws IOException if the camera's preview texture or display could not be initialized
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();

        // SurfaceTexture was introduced in Honeycomb (11), so if we are running and
        // old version of Android. fall back to use SurfaceView.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
            mCamera.setPreviewTexture(mDummySurfaceTexture);
        } else {
            mDummySurfaceView = new SurfaceView(mContext);
            mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
        }
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
CameraSource.java 文件源码 项目:BuddyBook 阅读 46 收藏 0 点赞 0 评论 0
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The preview
 * frames are not displayed.
 *
 * @throws IOException if the camera's preview texture or display could not be initialized
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();

        // SurfaceTexture was introduced in Honeycomb (11), so if we are running and
        // old version of Android. fall back to use SurfaceView.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
            mCamera.setPreviewTexture(mDummySurfaceTexture);
        } else {
            mDummySurfaceView = new SurfaceView(mContext);
            mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
        }
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
RxFusedLocationProviderClient.java 文件源码 项目:RxTask 阅读 38 收藏 0 点赞 0 评论 0
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Maybe<Location> getLastLocation() {
    return MaybeTask.create(() -> client.getLastLocation());
}


问题


面经


文章

微信
公众号

扫码关注公众号