Hi, i have implemented a crop image for Android 4.0.3 and Titanium sdk 2.1.0. I open the gallery of android , crop and save. My problem is that I cannot obtain the cropped image. In the Emulator works all fine and the path is returned in e1.intent.action. This is my code
Titanium.Media.openPhotoGallery({ success : function(event) { var image = event.media; var intent = Ti.Android.createIntent({ action: "com.android.camera.action.CROP", data: image.nativePath, type: 'image/*' }); intent.putExtra("outputX", 200); intent.putExtra("outputY", 200); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); var activity = Ti.Android.currentActivity; activity.startActivityForResult(intent, function(e1) { var pathImage: e1.intent.action; }); }, error:function(error) { }, cancel : function() { } });What is wrong?
Thank you
6 Answers
I tried your code, e1.intent.data is NULL and e1.intent.getStringExtra("data") IS NULL as well. Below is my code, i would appreciate it if you could direct me
var intent = Ti.Android.createIntent({ action: "com.android.camera.action.CROP", data: houseimage.nativePath, type: 'image/*' }); //intent.putExtra("crop", "true"); intent.putExtra("outputX", 200); intent.putExtra("outputY", 200); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); intent.putExtra(Ti.Android.EXTRA_STREAM, Ti.Filesystem.applicationDataDirectory); var activity = Ti.Android.currentActivity; activity.startActivityForResult(intent, function(param){ var toast = Ti.UI.createNotification({ message: JSON.stringify(param.intent.getStringExtra("data")) }); toast.show(); });
I am facing the same prob, did you find any solution to it
Yes, I have the solution. In the physical device the path of the cropped image is returned into:
e1.intent.dataThats works for me.
Hi, I'm having the same problem over here. It seems that the callback for activity.startActivityForResult is not being called at all. I can't retrieve the cropped picture...
I created a simple test project with my code here.
Note that navBarHidden:true and window.open({modal:true}); prevent to invoke activityResult.
Was anyone able to get this to work?
I can not seem to get a path to the newly saved cropped image. It gets stored in the gallery and everything.
Thanks.
Your Answer
Think you can help? Login to answer this question!