微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

项目:UnityBluetoothPlugin    文件BluetoothPlugin.java   
@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";
    }
}
项目:AndroidOCRFforID    文件CameraSourcePreview.java   
@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;
    }
}
项目:SocialPaka    文件CameraSource.java   
/**
 * 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;
}
项目:Barcode-Reader    文件CameraSourcePreview.java   
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException,mCameraSource.getCameraFacing());
            }
            mOverlay.clear();
        }
        mStartRequested = false;
    }
}
项目:ConcealSharedPreference-Android    文件ConcealPrefRepository.java   
@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;
}
项目:Fuse    文件CameraSourcePreview.java   
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException,mCameraSource.getCameraFacing());
            }
            mOverlay.clear();
        }
        mStartRequested = false;
    }
}
项目:Barcode-Reader    文件CameraSource.java   
/**
 * 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;
}
项目:Toodoo    文件CameraSource.java   
/**
 * 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;
}
项目:BuddyBook    文件CameraSourcePreview.java   
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException,mCameraSource.getCameraFacing());
            }
            mOverlay.clear();
        }
        mStartRequested = false;
    }
}
项目:BuddyBook    文件CameraSource.java   
/**
 * 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;
}
项目:android-location-Tracker    文件LocationService.java   
@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");
    }
}
项目:trust-wallet-android    文件CameraSource.java   
/**
 * 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;
}
项目:Camera2Vision    文件Camera2Source.java   
/**
 * 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;
}
项目:garras    文件BigImageView.java   
@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);
        }
    }
}
项目:mapBox-plugins-android    文件LocationLayerPlugin.java   
/**
 * 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);
  }
}
项目:UnityBluetoothPlugin    文件BluetoothPlugin.java   
@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";
    }
}
项目:UnityBluetoothPlugin    文件BluetoothPlugin.java   
@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();
}
项目:smart-asset-iot-android-demo    文件RxLocationManager.java   
@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"));
}
项目:smart-asset-iot-android-demo    文件RxLocationManager.java   
@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"));
}
项目:Toodoo    文件CameraSource.java   
/**
 * 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;
}
项目:ConcealSharedPreference-Android    文件ConcealPrefRepository.java   
@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;
}
项目:ConcealSharedPreference-Android    文件ConcealPrefRepository.java   
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE,@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;
}
项目:BluetoothKit    文件BluetoothJellyBean.java   
@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;
    }
}
项目:BluetoothKit    文件BluetoothJellyBean.java   
@SuppressWarnings("deprecation")
@RequiresPermission(allOf = {Manifest.permission.BLUetoOTH_ADMIN,Manifest.permission.BLUetoOTH})
@Override
public void stopScanInternal() {
    if(isScanning){
        bluetoothAdapter.stopLeScan(this);

        isScanning = false;
    }
}
项目:UnityBluetoothPlugin    文件BluetoothPlugin.java   
@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();
    }

}
项目:Fuse    文件CameraSource.java   
/**
 * 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;
}
项目:AndroidOCRFforID    文件CameraSourcePreview.java   
@RequiresPermission(Manifest.permission.CAMERA)
public void start(CameraSource cameraSource) throws IOException,SecurityException {
    if (cameraSource == null) {
        stop();
    }

    mCameraSource = cameraSource;

    if (mCameraSource != null) {
        mStartRequested = true;
        startIfReady();
    }
}
项目:trust-wallet-android    文件CameraSource.java   
/**
 * 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;
}
项目:BuddyBook    文件CameraSource.java   
/**
 * 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;
}
项目:RxTask    文件RxFusedLocationProviderClient.java   
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION","android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Maybe<Location> getLastLocation() {
    return MaybeTask.create(() -> client.getLastLocation());
}
项目:Rx_java2_soussidev    文件ReactiveNetwork.java   
/**
 * Observes network connectivity. @R_720_4045@ion about network state,type and typeName are contained
 * in
 * observed Connectivity object.
 *
 * @param context Context of the activity or an application
 * @return RxJava Observable with Connectivity class containing @R_720_4045@ion about network state,* type and typeName
 */
@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE)
public static Observable<Connectivity> observeNetworkConnectivity(final Context context) {
    final NetworkObservingStrategy strategy;

    if (Preconditions.isAtLeastAndroidMarshmallow()) {
        strategy = new MarshmallowNetworkObservingStrategy();
    } else if (Preconditions.isAtLeastAndroidLollipop()) {
        strategy = new LollipopNetworkObservingStrategy();
    } else {
        strategy = new PreLollipopNetworkObservingStrategy();
    }

    return observeNetworkConnectivity(context,strategy);
}
项目:BluetoothKit    文件BluetoothLollipop.java   
@RequiresPermission(allOf = {Manifest.permission.BLUetoOTH_ADMIN,Manifest.permission.BLUetoOTH})
@Override
public void stopScanInternal() {
    if (isScanning) {
        bluetoothLeScanner.stopScan(scanCallback);

        isScanning = false;
    }
}
项目:Rx_java2_soussidev    文件ReactiveNetwork.java   
/**
 * Checks connectivity with the Internet. This operation is performed only once.
 *
 * @param strategy which implements InternetobservingStrategy
 * @return RxJava Single with Boolean - true,when we have an access to the Internet
 * and false if not
 */
@RequiresPermission(Manifest.permission.INTERNET)
public static Single<Boolean> checkInternetConnectivity(
        final InternetobservingStrategy strategy) {
    checkStrategyIsNotNull(strategy);
    return strategy.checkInternetConnectivity(strategy.getDefaultPingHost(),DEFAULT_PING_PORT,DEFAULT_PING_TIMEOUT_IN_MS,new DefaultErrorHandler());
}
项目:selimg    文件SelimgBottomSheet.java   
@RequiresPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
@Override
public void openImageFromCamera() {
    if (ContextCompat.checkSelfPermission(getContext(),Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED && ContextCompat
            .checkSelfPermission(getContext(),Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
        openImageFromCameraIntent();
    } else {
        requestPermissions(new String[]{
                Manifest.permission.CAMERA,Manifest.permission.WRITE_EXTERNAL_STORAGE
        },REQUEST_WRITE_EXTERNAL_PERMISSION);
    }
}
项目:UnityBluetoothPlugin    文件BluetoothService.java   
@RequiresPermission("android.permission.BLUetoOTH")
public synchronized void connect(BluetoothDevice device) {
    Log.d(TAG,"connect to: " + device);

    // Cancel any thread attempting to make a connection
    if (mState == STATE_CONNECTING) {
        if (mConnectThread == null) {

        } else {
            mConnectThread.cancel();
            mConnectThread = null;
        }
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread == null) {

    } else {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    // Start the thread to connect with the given device
    mConnectThread = new BluetoothService.ConnectThread(device);
    mConnectThread.start();

    setState(STATE_CONNECTING);
}
项目:OCR-Reader    文件CameraSourcePreview.java   
@RequiresPermission(Manifest.permission.CAMERA)
public void start(CameraSource cameraSource) throws IOException,SecurityException {
    if (cameraSource == null) {
        stop();
    }

    mCameraSource = cameraSource;

    if (mCameraSource != null) {
        mStartRequested = true;
        startIfReady();
    }
}
项目:OCR-Reader    文件CameraSource.java   
/**
 * 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;
}
项目:ModuleFrame    文件NetworkUtil.java   
/**
 * 判断网络是否连接
 *
 * @param context 上下文
 * @return  {@code true}: 可用<br>{@code false}: 不可用
 */
@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE)
public static boolean isConnected(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivityManager != null) {
        NetworkInfo info = connectivityManager.getActiveNetworkInfo();
        return info != null && info.isConnected();
    }
    return false;
}
项目:silly-android    文件SillyAndroid.java   
/**
 * Checks if WiFi is enabled and connected to a network.
 * <b>Note</b>: This does not check access to the Internet.
 *
 * @param context Which context to use to check
 * @return {@code True} if WiFi is enabled and connected to a network,{@code false} otherwise
 */
@RequiresPermission(Manifest.permission.ACCESS_WIFI_STATE)
public static boolean isWifiConnected(@NonNull final Context context) {
    final WifiManager wiFiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if (wiFiManager != null && wiFiManager.isWifiEnabled()) {
        // Wi-Fi adapter is ON
        final WifiInfo wifiInfo = wiFiManager.getConnectionInfo();
        return wifiInfo != null && wifiInfo.getNetworkId() != -1;
    } else {
        // Wi-Fi adapter is OFF
        return false;
    }
}
项目:silly-android    文件SillyAndroid.java   
/**
 * Checks if device is connected to other,non-WiFi networks.
 * <b>Note</b>: This does not check access to the Internet.
 *
 * @param context Which context to use to check
 * @return {@code True} if there is a non-WiFi network connected,{@code false} if not
 */
@RequiresPermission(allOf = {Manifest.permission.ACCESS_WIFI_STATE,Manifest.permission.ACCESS_NETWORK_STATE})
public static boolean isNonWifiNetworkConnected(@NonNull final Context context) {
    final ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo networkInfo = connectivityManager == null ? null : connectivityManager.getActiveNetworkInfo();
    boolean hasOtherNetwork = false;
    if (networkInfo != null && networkInfo.isConnected()) {
        hasOtherNetwork = true;
    }
    return hasOtherNetwork && !isWifiConnected(context);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。