I'm using the official cordova camera plugin in order to load an image to an tag from a photo library, so I made a button to call the navigator.camera.GetPicture() method. After the click event on the bottom of the screen I get a "Get Picture" modal/toast with two options where can I browse my pictures: Gallery or Photos. If I choose the gallery everything works fine and I can repeat this multiple times. But If I choose the photos option I almost always get an error: "refused to load the image because it violates the following..." So any idea? I tried to modify the meta tags, but no result. Or how can I force the browsing only the gallery?
Thanks,
You can configure the options.
var cameraRollOptions = {
'sourceType': window.navigator.camera.PictureSourceType.PHOTOLIBRARY,
};
window.navigator.camera.getPicture(successHandler, errorHandler, cameraRollOptions);
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/index.html#cameraoptions-errata-
Related
For my app, I'm using the Cordova CameraPreview plugin, to take pictures.
Once, a picture is taken, I get a path like this (and a 2nd one for the thumbnail, but not more):
/data/data/com.foo.bar/files/filename.jpg
Including the picture via
<img src="/data/data/...">
it works fine, so the path seems to be valid.
However, if I try to delete pictures, it doesn't work.
My Code:
window.resolveLocalFileSystemURL(the_path, function (result) {
alert("I'm in");
result.remove(function(){
alert("removed image");
});
});
The I'm in alert doesn't appear, in my console (Android Studio) I get the following error:
java.net.MalformedURLException: No installed handlers for this URL
Do I have to modify the URL, or what's wrong?
I found a solution via trial and error.
prepending
file://
to the path, so that it looks like
file:///data/data/com.foo.bar/files/filename.jpg
worked for me. But I've no idea, if this works in iOS, too.
I'm trying to build a Vine-like app using the Ionic Framework. I've got the mediaCapture plugin working but it uses the native camera functionality. The user has to leave me app to record video using the native interface and then return to my app. How can add a button and camera controls within my app like Vine or Instagram?
You can use Camera plugin.
This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the system's image library.
If you want to get video file type of gallery, you can use mediaType, like this:
Camera.MediaType = {
PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
VIDEO: 1, // allow selection of video only, WILL ALWAYS RETURN FILE_URI
ALLMEDIA : 2 // allow selection from all media types
};
I'm creating an app where the user will use the camera or choose some photos from the gallery.
I'm trying to put some rules when the user chooses the photo from the album but I don't know all the properties and I tried to search some site or tutorial but I didn't found anything.
Someone knows where I can find this or learn the properties.
Properties like this
intent.putExtra("crop","true");
intent.putExtra("aspectX",10);
intent.putExtra("aspectY",10);
intent.putExtra("outputX",256);
intent.putExtra("outputY",256);
intent.putExtra("return-data",true);
I need to disable the resize function from the crop screen and I want to learn more about working with an android camera.
Thanks and regards to everyone.
"return-data"
"cropped-rect"
"aspectX"
"aspectY"
"spotlightX"
"spotlightY"
"outputX"
"outputY"
"scale"
"data"
"scaleUIfNeeded"
"outputFormat"
"set-as-wallpaper"
"noFaceDetection"
I refer you to Mr. Murphy's post here: http://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html
I've been trying to figure out how to display a photo on Android. I can create an ImageView and display a picture, but the functionality is limited (no zoom, pan or share). Is there a demo or tutorial with code out there on how to do this? I've been searching all week with no luck.
Thanks.
P.S.> Please No Snark!
Maybe I don't understand how to create a uri correctly or how to make my resource available to the viewer. I have a resource ID, R.drawable.opal, I'm using to display different minerals and gems for a science project. If the student clicks the small sample photo, then I want to bring up a bigger and better viewer for the photo to allow them to compare to their collected rock.
Unless you really need to build your own you should probably just use the gallery's viewer. Send it the picture by using the view intent like so:
Intent viewImageIntent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(viewImageIntent);
Replace "uri" with the image's uri of course. Writing your own viewer is really involved and would include threading, physics calculations and handling touch inputs.
I am searching an ImageViewer library that opens an image in my application for a given URI (the image fetched by a webservice is already stored within my application in a secured place). I really like the "Samsung Galaxy S" ImageViewer-Activity because it uses pinch-zoom and "scrolling" vertical/horizontal. Also it scales the picture very fast on my samsung phone :)
I know that I can open an image with an intent like this:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, "image/*");
startActivity(i);
The best suitable viewer is being called, when none is found an ActivityNotFoundException is raised. So thats cool!
But the problem is that I am not allowed to open an image with an external intent (for security purposes). i.e: The user should not have the posibility to save the opened image via a menu option to his external sd-card or send this picture to another service (email/twitter or s.o.). So I have to write my own ImageViewer-Class (Activity) that can only be called within my application...
Unfortunately I am not very skilled transforming images, so is there any open source project (or library) that covers this use case?
I already asked google and found this one http://code.google.com/p/android-pinch/ but it didnt work very well (also it has no scroll-functionality).
Thanks for your tips :)
At this moment I'm too use WebView. But this is conceptually wrong, WebView is not for displaying images, it for displaying web content. WebView is bulky and cumbersome. You restricted in customizing it. For example, I need scaling, but I don't want to see zoom controls, or I want to move them in other place then default.
Therefore, I searched about this problem and found some solutions:
PhotoView widget from Chris Banes
Also, you can look at this tutorial from Sony Ericsson (sources available) and can implement your own widget: part1, part2, part3
And another one library ImageViewZoom at github
UPDATE
Chris Banes was created awesome library which supports gestures for zooming pictures, see first point above
The easiest way to handle images is using a WebView, if the image is stored local or somewhere online. WebView supports pinch to zoom and other functions.
Example Java:
String imageUrl = "file:///local/dir/image.jpg"; // http://example.com/image.jpg
WebView wv = (WebView) findViewById(R.id.yourwebview);
wv.getSettings().setBuiltInZoomControls(true);
wv.loadUrl(imageUrl);
XML source:
<WebView android:id="#+id/yourwebview"
android:layout_width="match_parent"
android:layout_height="match_parent" />