Environment: Titanium SDK 3.1.1.GA, Android SDK 4.0.3, Phone: Samsung Galaxy S III Problem: Saving photos and retrieving photos works fine in Android Emulator but does not work in Android phone (only 2 photos show up on the device)
After the photo has been taken, I am assigning a file name (unique) and save the file name into the database. During the display, I retrieve the file name from the database and retrieve the image. Photo is getting saved in the device in the specified path.
I have read through the forum and various Q&A and still not able to figure out why only 2 photos show up in the scrollview whereas in the Android Emulator any number of photos show up.
Code:
Photo saving:
Titanium.Media.showCamera({
success:function(event) { var image = event.media; var db = Titanium.Database.open('table1'); var imgsPath = Ti.Filesystem.externalStorageDirectory + 'projImages' + Ti.Filesystem.separator; var userDir = Ti.Filesystem.getFile(imgsPath); userDir.createDirectory(); var filename = 'projImage'+new Date().getTime()+'.png'; var f = Ti.Filesystem.getFile(userDir.nativePath,filename); db.execute('INSERT INTO my_photos("age_id","act_id","sub_id","image_id") Values ("'+Ti.App.ageId.ageDesc+'","'+Ti.App.actId.actDesc+'","'+Ti.App.subact.sact+'","'+f.nativePath+'")'); if (f.exists()) { Ti.API.info('The file exist , trying to delete it before using it :' + f.deleteFile()); f = Titanium.Filesystem.getFile(userDir.nativePath,filename); } f.write(image); db.close(); }, saveToPhotoGallery:true, allowEditing:true, mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO],
});
Photo Retrieving:
var scrollView = Ti.UI.createScrollView({ contentWidth: 'auto', contentHeight: 'auto', showVerticalScrollIndicator: false, showHorizontalScrollIndicator: true, height: '30%', width: '100%', left:'0%', top:'40%' }); win8.add(scrollView);
var db = Titanium.Database.open('table1'); var dbImageRows=db.execute('Select image_id from my_photos WHERE age_id = "'+Ti.App.ageId.ageDesc+'" and act_id="'+Ti.App.actId.actDesc+'" and sub_id="'+Ti.App.subact.sact+'"');
var imageView=[]; var i = 0; var temp=0; while(dbImageRows.isValidRow()){ imageView[i] = Ti.UI.createImageView({ top:'0%', width:'100dp', height:'100dp', left:temp+'dp', image:dbImageRows.fieldByName("image_id") }); temp=temp+130 scrollView.add(imageView[i]); i++; dbImageRows.next();
} db.close();
Any help is greatly appreciated.
Thanks!
Jill Kelly McKayla Maroney gronkowski jeremy renner best buy black friday deals breaking dawn part 2 breaking dawn part 2
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.