How to use Android’s camera or camera2 API to support old and new API versions without deprecation notes?

Even though the old camera API is marked as deprecated, it is still fully functional, and will remain so for quite a while (as nearly all camera-using applications on the Play Store use it currently). You’ll have to ignore Android Studio’s complaints about it being deprecated, but if you want to support Android versions earlier … Read more

Camera access through browser

You could try this: <input type=”file” capture=”camera” accept=”image/*” id=”cameraInput” name=”cameraInput”> but it has to be iOS 6+ to work. That will give you a nice dialogue for you to choose either to take a picture or to upload one from your album i.e. An example can be found here: Capturing camera/picture data without PhoneGap

Detect permission of camera in iOS

Check the AVAuthorizationStatus and handle the cases properly. NSString *mediaType = AVMediaTypeVideo; AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType]; if(authStatus == AVAuthorizationStatusAuthorized) { // do your logic } else if(authStatus == AVAuthorizationStatusDenied){ // denied } else if(authStatus == AVAuthorizationStatusRestricted){ // restricted, normally won’t happen } else if(authStatus == AVAuthorizationStatusNotDetermined){ // not determined?! [AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) { … Read more

Android ACTION_IMAGE_CAPTURE Intent

this is a well documented bug in some versions of android. that is, on google experience builds of android, image capture doesn’t work as documented. what i’ve generally used is something like this in a utilities class. public boolean hasImageCaptureBug() { // list of known devices that have the bug ArrayList<String> devices = new ArrayList<String>(); … Read more

NSCameraUsageDescription in iOS 10.0 runtime crash?

After iOS 10 you have to define and provide a usage description of all the system’s privacy-sensitive data accessed by your app in Info.plist as below: Calendar Key : Privacy – Calendars Usage Description Value : $(PRODUCT_NAME) calendar events Reminder : Key : Privacy – Reminders Usage Description Value : $(PRODUCT_NAME) reminder use Contact : … Read more

How to save picture to iPhone photo library?

You can use this function: UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo); You only need completionTarget, completionSelector and contextInfo if you want to be notified when the UIImage is done saving, otherwise you can pass in nil. See the official documentation for UIImageWriteToSavedPhotosAlbum().

How to access a mobile’s camera from a web app?

In iPhone iOS6 and from Android ICS onwards, HTML5 has the following tag which allows you to take pictures from your device: <input type=”file” accept=”image/*” capture=”camera”> Capture can take values like camera, camcorder and audio. I think this tag will definitely not work in iOS5, not sure about it.

Capture Image from Camera and Display in Activity

Here’s an example activity that will launch the camera app and then retrieve the image and display it. package edu.gvsu.cis.masl.camerademo; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MyCameraActivity extends Activity { private static final int CAMERA_REQUEST = 1888; private ImageView imageView; private static final int MY_CAMERA_PERMISSION_CODE … Read more

AVFoundation, how to turn off the shutter sound when captureStillImageAsynchronouslyFromConnection?

I used this code once to capture iOS default shutter sound (here is list of sound file names https://github.com/TUNER88/iOSSystemSoundsLibrary): NSString *path = @”/System/Library/Audio/UISounds/photoShutter.caf”; NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSData *data = [NSData dataWithContentsOfFile:path]; [data writeToFile:[docs stringByAppendingPathComponent:@”photoShutter.caf”] atomically:YES]; Then I used third-party app to extract photoShutter.caf from Documents directory (DiskAid for Mac). Next step … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)