I am developing an Android app that needs to have the functionality to take a picture and share it with the Instagram app. The application opens the camera, takes a picture, and then the Instagram application opens with the "Crop Photo" window. It seems that the image is loading, but after a couple of seconds the application crashes, I do not see that the image is ever loading.
I am developing an application on top of the Appcelerators Titanium platform, however I do not think that my problem is with titanium, but rather how I transmit the image.
Since the emulator does not have an Instagram application, I am developing on my Galaxy S4. I tried running logcat via adb to get some kind of error message to help me, but the only thing I see is that it notices that Instagram exited.
Here is my code, what could be wrong? I checked that the image is saved in the file system.
Ti.Media.showCamera({ success: function(event) { var file = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory,"ggs-instagram.jpg"); file.write(event.media); var instaIntent = Ti.Android.createIntent({ action: Ti.Android.ACTION_SEND, packageName: "com.instagram.android", type: 'image/jpeg' }); instaIntent.putExtra(Ti.Android.EXTRA_STREAM, file.getNativePath()); Ti.Android.currentActivity.startActivity(instaIntent); }, cancel: function() {}, error: function (error) { if (error.code == Ti.Media.NO_CAMERA) { alert("Din telefon/platta har ingen kamera!"); } else { alert("Kamerafel!"); } }, mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO], showControls: false, autohide: false, saveToPhotoGallery: true });
source share