How to open only default android camera in cordova:
In my phone tow camera one is default camera and second is Beautify aap. I want to open only my default camera only by using cordova.
please use following plugin
cordova plugin add org.apache.cordova.camera
this function will open camera app,
$scope.takePicture = function (options) {
var options = {
quality : 75,
targetWidth: 200,
targetHeight: 200,
sourceType: 1
};
Camera.getPicture(options).then(function(imageData) {
$scope.picture = imageData;;
}, function(err) {
console.log(err);
});
};
if above function is opening Beautify camera app,then you have selected it as default camera app,please check in phone settings.
Clear defaults from Beautify camera app
For references:
Tutorial 1
Tutorial 2
Related
I am trying to select gif files using expo-image-picker. However, it doesn't select the gif file in android, it selects the first frame of the gif even when quality is set to undefined and allowsEditing to false.
Version of expo - 46.0.9, Version of expo-image-picker - 13.3.1. Here's a reproducible demo - snack demo
Expected behavior on android:
Actual behavior on android:
I had this issue myself and found a solution.
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
// allowsEditing: false,
// aspect: aspect,
quality: 1,
// exif: false
});
i am using react-native-image-crop-picker library as camera but when i open camera getting chooser option to select any one camera app i want to directly open default camera without showing chooser options from react native
You can use this:
ImagePicker.openCamera({
width: 300,
height: 400,
cropping: true,
}).then(image => {
console.log(image);
});
You can directly invoke the function provided by react-native-image-crop
it is called openCamera for camera opening
you can use it as the following
ImagePicker.openCamera({
...your camera config
}).then(image => {
console.log(image);
});
I am using Ionic 2 for an app and I have a question regarding the ionic-native plugin - Camera. There any way to use the Camera only or photo gallery only inside of an Ionic 2 Application. using the option sourcetype CAMERA or PHOTOALBUM.
Is there a way where I can use both at the same time. Like in Whatsapp, when you want to send an image tou can take a picture at the same time or use a picture from photo gallery.
Any ideas?
I think the best option is to show an action sheet (or something like that) in which the user can select an action (Camera or Album). Then create separate methods for both functionalities and call the desired method (this isn't a full implementation):
function getPictureFromCamera() {
Camera.getPicture({
...
sourceType: 'CAMERA'
}).then(...);
...
}
function getPictureFromAlbum() {
Camera.getPicture({
...
sourceType: 'PHOTOLIBRARY'
}).then(...);
...
}
Here are the steps to reproduce:
Create a basic ionic project ionic start test sidemenu
Add the android platform ionic platform add android
In app.js add the code:
$ionicPlatform.registerBackButtonAction(function (event) {
alert("back button action handler");
event.preventDefault();
}, 999);
This code can be added in the .run method or in the $ionicPlatform.ready() method - same result, not working
ionic build android then ionic upload -> or manually put the APK on a device
[BUG]
- the alert is not shown and history view navigation is performed. It's like this action that I try to register is not taken into consideration.
What am I doing wrong? I tried this code in a controller also, also e.stopPropagation() or e.stopImmediatePropagation still no success.
I have the latest Ionic (1.4.5) and Cordova 4.3.0, tested on some Samsung devices. In Ripple, it works ok.
try preventing the default first
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
alert("back button action handler");
}, 999);
Also the code 999 is perfectly valid, the codes 100, 200, 300, 400, 500 are just the priorities that ionic asigns to certain actions of the back button. I've used multiple times the priority 900, it just puts your backbutton on top of all other action.
More information in the documentation : http://ionicframework.com/docs/api/service/$ionicPlatform/
Can you use code 999?
Here that info about 100, 200, 300, 400, 500, but not 900.
http://ionicframework.com/docs/api/service/$ionicPlatform/
I use code for example 501 and this works.
That is example from my project which works
$scope.$on("$ionicView.enter", function () {
$ionicPlatform.registerBackButtonAction(registerBackButtonAction, 501);
});
function registerBackButtonAction(e) {
if (!!e && typeof e.preventDefault === 'function') {
e.preventDefault();
}
// some code
return false;
}
I am developing android application, In my application I want to take photo from camera and set as image in image view. my code looks like
var img_view = Titanium.UI.createImageView({
image: '/images/default.png',
height: '100%',
width: '100%',
}); win.add(img_view);
photo_camera_view = Ti.UI.createView(
{
height: '20dp',
backgroundColor:'#fff'
}); win.add(photo_camera_view);
photo_camera_view.addEventListener('click', function(e)
{
Titanium.Media.showCamera(
{
success:function(event)
{
img_view.image = event.media;
},
cancel:function()
{
},
error:function(error)
{
// create alert
},
});
});
my need is take a pic from camera and set image: 'photo from camera' in img_view. In Android, when I execute Ti.Media.showCamera, after successfully taking a picture and hitting "OK" in the app, the application will restart. I am using titanium sdk 2.0.1 and testing it on android device with android version 2.2. Need Help ..... Thank you........
You need to set the image in the success event like below.
img_view.setImage(event.media);
You just cannot assign the image to the property. The image view has to be redrawn with new image. And try it in Android 4.0 emulator as the below versions had issues with camera.