Last active
December 30, 2015 21:39
-
-
Save MotiurRahman/7889350 to your computer and use it in GitHub Desktop.
Trying to create an image from thumbnail on Android, crashes the app on some devices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Hi I have tested this jira ticket and it's not a bug. After running this code if you click the Take_Photo button take a picture | |
| and create it thumbnail image successfully. | |
| Testing Environment: | |
| Android SDK: 4.2.2 | |
| Titanium SDK: 3.1.3 | |
| Steps to Reproduce: | |
| 1.Create a simple project | |
| 2.Paste this code in app.js file. | |
| 3.Run This in a real device with testing environment. | |
| */ | |
| var win = Ti.UI.createWindow({ | |
| backgroundColor : '#000', | |
| layout : 'vertical', | |
| navBarHidden : false, | |
| title : 'Take a Photo From Camara' | |
| }); | |
| var takePhoto = Ti.UI.createButton({ | |
| title : 'Take_Photo', | |
| color : '#000', | |
| width : Ti.UI.SIZE, | |
| height : 60, | |
| top : 10, | |
| }); | |
| var image = Ti.UI.createImageView({ | |
| top : 10, | |
| height : Ti.UI.SIZE, | |
| width : Ti.UI.SIZE, | |
| }); | |
| win.add(takePhoto); | |
| win.add(image); | |
| //win.add(anImageView); | |
| takePhoto.addEventListener('click', function() { | |
| fireUpTheCamera(); | |
| }); | |
| function fireUpTheCamera() { | |
| Titanium.Media.showCamera({ | |
| success : function(event) { | |
| var cropRect = event.cropRect; | |
| var photo = event.media; | |
| Ti.API.debug('Our type was: ' + event.mediaType); | |
| if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { | |
| image.setImage(photo.imageAsThumbnail(129, 0, 0)); | |
| //image.setImage(photo); | |
| } else { | |
| alert("got the wrong type back =" + event.mediaType); | |
| } | |
| }, | |
| cancel : function() { | |
| }, | |
| error : function(error) { | |
| // create alert | |
| var a = Titanium.UI.createAlertDialog({ | |
| title : 'Camera' | |
| }); | |
| // set message | |
| if (error.code == Titanium.Media.NO_CAMERA) { | |
| a.setMessage('Please run this test on device'); | |
| } else { | |
| a.setMessage('Unexpected error: ' + error.code); | |
| } | |
| // show alert | |
| a.show(); | |
| }, | |
| saveToPhotoGallery : false, | |
| allowEditing : false, | |
| mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO] | |
| }); | |
| } | |
| win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment