Creating Facebook app for Android - quesiton

rxmarccall,

Sounds like you’ve found a bug with display.save(). It may be device specific or its the pixel size of the image that you are capturing (ie: a stride issue), because this issue does not happen on my Galaxy Nexus. Probably some edge case that we didn’t think of.

Would you mind sending us a small sample project that reproduces this display.save() issue please? You can do so by clicking the “Report a Bug” link at the top of this web page. [import]uid: 32256 topic_id: 32551 reply_id: 130108[/import]

@Joshua,
I submitted a bug report as requested. As I built a demo to show the issue I found what seems to be causing the issue. When my project had no “config” file, there was no issue. Once I put in my projects “config” file that set the applications content width and height, then the crazy warping on the saved image is happening. Hope this one can get resolved somewhat quick so I can get my app out!

Thanks [import]uid: 19620 topic_id: 32551 reply_id: 130236[/import]

@Joshua,
I submitted a bug report as requested. As I built a demo to show the issue I found what seems to be causing the issue. When my project had no “config” file, there was no issue. Once I put in my projects “config” file that set the applications content width and height, then the crazy warping on the saved image is happening. Hope this one can get resolved somewhat quick so I can get my app out!

Thanks [import]uid: 19620 topic_id: 32551 reply_id: 130236[/import]

I’m thinking that this must be a “stride” issue. That is, the image comes out skewed because the number of pixels along the horizontal axis is not a multiple of 4. I also suspect that this only happens on particular Android devices. I say this because I remember something similar happening to one other person, but I wasn’t able to reproduce it with his project on my Android devices.

So, can you tell me the make and model of the Android device that you are using please? [import]uid: 32256 topic_id: 32551 reply_id: 130255[/import]

I’m thinking that this must be a “stride” issue. That is, the image comes out skewed because the number of pixels along the horizontal axis is not a multiple of 4. I also suspect that this only happens on particular Android devices. I say this because I remember something similar happening to one other person, but I wasn’t able to reproduce it with his project on my Android devices.

So, can you tell me the make and model of the Android device that you are using please? [import]uid: 32256 topic_id: 32551 reply_id: 130255[/import]

@Joshua,
Sure, my phone is the “Samsung Galaxy SIII”. My brother also had the same issue and he has the “HTC One S” [import]uid: 19620 topic_id: 32551 reply_id: 130324[/import]

@Joshua,
Sure, my phone is the “Samsung Galaxy SIII”. My brother also had the same issue and he has the “HTC One S” [import]uid: 19620 topic_id: 32551 reply_id: 130324[/import]

Hi,

I added code to login to Facebook with only using the app id and did not do anything else on the app page in the developers page. I didn’t enter a class name or hash and when i try to login it lets me. But when i try to upload a photo it says it was a success but it’s not on my Facebook page. Is this still because I do not have anything else configured on the Facebook developers page? If so, why did it say I am logged in and the photo uploaded? This is for Android and below is my code. The app id is removed on this page.

UPDATE: Since I posted this I did the following. I commented out the line to upload the photo and instead had it just post a message. This works! The message appeared on my Facebook page. I then noticed I was calling the picture from the wrong directory and fixed it and tried again. It seemed longer before it said the image was uploaded but nothing appears on my page with the POST. Any suggestions why it works with the message but not with the attachment and the picture? Thanks!!

 --facebook.request( "me/feed", "POST", attachment )  
 facebook.request( "me/feed", "POST", {message = "Hello Facebook"} )  

Thanks

-----------------------------------------------------------------------------------------  
  
--  
  
-- main.lua  
  
--  
  
-----------------------------------------------------------------------------------------  
local facebook = require "facebook"  
local appId = "removed"  
local widget = require "widget"  
  
local onComplete = function(event)  
 local photo = event.target  
 photo.isVisible = false  
 facebook.login( "removed", fbListener, { "publish\_stream" } )  
end  
  
 local function fbListener( event )  
 if event.isError then  
 native.showAlert( "ERROR", event.response, { "OK" } )  
 else  
 if event.type == "session" and event.phase == "login" then  
 -- login was a success; call function  
 native.showAlert( "Success", "You are logged into Facebook!.", { "OK" } )   
 --onLoginSuccess()  
  
  
 elseif event.type == "request" then  
 -- this block is executed upon successful facebook.request() call  
   
  
 native.showAlert( "Success", "The photo has been uploaded.", { "OK" } )  
 end  
 end  
end  
  
local function onLoginSuccess()  
 -- Upload 'iheartcorona.jpg' to current user's account  
 local attachment = {  
 message = "Just a description of the photo.",  
 source = { baseDir=system.TemporaryDirectory, filename="CameraShot.jpg", type="image" }  
 }  
 facebook.request( "me/photos", "POST", attachment )  
end  
  
local onComplete = function(event)  
 if event.completed then  
  
 -- Camera shot was successfully taken.  
  
 -- Display at full resolution by passing in true.  
  
 -- display.newImage("CameraShot.jpg", system.TemporaryDirectory, true)  
 local attachment = {  
 message = "Just a description of the photo.",  
 source = { baseDir=system.TemporaryDirectory, filename="CameraShot.jpg", type="image" }  
 }  
  
  
 facebook.request( "me/photos", "POST", attachment )  
  
 else  
  
 -- User canceled out.  
  
 end  
end  
  
local listener = function( event )  
 if media.hasSource( media.Camera ) then  
 local filePath = { baseDir = system.TemporaryDirectory, filename = "CameraShot.jpg" }  
 media.show( media.Camera, onComplete, filePath )  
 else  
 native.showAlert("Corona", "Camera not found.")  
 end  
 return true  
end  
  
local onbtnLoginEvent = function (event )  
 if event.phase == "release" then  
 print( "You pressed and released a button!" )  
 --native.showAlert( "Success", "The button was pressed!.", { "OK" } )  
 facebook.login( appId, fbListener, { "publish\_stream" } )  
 end  
end  
  
local onbtnCameraEvent = function (event )  
 if event.phase == "release" then  
 local filePath = { baseDir = system.TemporaryDirectory, filename = "CameraShot.jpg" }  
 media.show( media.Camera, onComplete, filePath )  
 end  
end  
  
local btnLogin = widget.newButton{  
 id = "btn001",  
 left = 100,  
 top = 200,  
 label = "Facebook Login",  
 width = 170, height = 28,  
 cornerRadius = 8,  
 onEvent = onbtnLoginEvent  
}  
  
btnLogin.x = 100  
btnLogin.y = 200  
  
local btnCamera = widget.newButton{  
 id = "btn002",  
 left = 100,  
 top = 400,  
 label = "Take Picture",  
 width = 170, height = 28,  
 cornerRadius = 8,  
 onEvent = onbtnCameraEvent  
}   
  
btnCamera.x = 100  
btnCamera.y = 400  

[import]uid: 184193 topic_id: 32551 reply_id: 130452[/import]

Hi,

I added code to login to Facebook with only using the app id and did not do anything else on the app page in the developers page. I didn’t enter a class name or hash and when i try to login it lets me. But when i try to upload a photo it says it was a success but it’s not on my Facebook page. Is this still because I do not have anything else configured on the Facebook developers page? If so, why did it say I am logged in and the photo uploaded? This is for Android and below is my code. The app id is removed on this page.

UPDATE: Since I posted this I did the following. I commented out the line to upload the photo and instead had it just post a message. This works! The message appeared on my Facebook page. I then noticed I was calling the picture from the wrong directory and fixed it and tried again. It seemed longer before it said the image was uploaded but nothing appears on my page with the POST. Any suggestions why it works with the message but not with the attachment and the picture? Thanks!!

 --facebook.request( "me/feed", "POST", attachment )  
 facebook.request( "me/feed", "POST", {message = "Hello Facebook"} )  

Thanks

-----------------------------------------------------------------------------------------  
  
--  
  
-- main.lua  
  
--  
  
-----------------------------------------------------------------------------------------  
local facebook = require "facebook"  
local appId = "removed"  
local widget = require "widget"  
  
local onComplete = function(event)  
 local photo = event.target  
 photo.isVisible = false  
 facebook.login( "removed", fbListener, { "publish\_stream" } )  
end  
  
 local function fbListener( event )  
 if event.isError then  
 native.showAlert( "ERROR", event.response, { "OK" } )  
 else  
 if event.type == "session" and event.phase == "login" then  
 -- login was a success; call function  
 native.showAlert( "Success", "You are logged into Facebook!.", { "OK" } )   
 --onLoginSuccess()  
  
  
 elseif event.type == "request" then  
 -- this block is executed upon successful facebook.request() call  
   
  
 native.showAlert( "Success", "The photo has been uploaded.", { "OK" } )  
 end  
 end  
end  
  
local function onLoginSuccess()  
 -- Upload 'iheartcorona.jpg' to current user's account  
 local attachment = {  
 message = "Just a description of the photo.",  
 source = { baseDir=system.TemporaryDirectory, filename="CameraShot.jpg", type="image" }  
 }  
 facebook.request( "me/photos", "POST", attachment )  
end  
  
local onComplete = function(event)  
 if event.completed then  
  
 -- Camera shot was successfully taken.  
  
 -- Display at full resolution by passing in true.  
  
 -- display.newImage("CameraShot.jpg", system.TemporaryDirectory, true)  
 local attachment = {  
 message = "Just a description of the photo.",  
 source = { baseDir=system.TemporaryDirectory, filename="CameraShot.jpg", type="image" }  
 }  
  
  
 facebook.request( "me/photos", "POST", attachment )  
  
 else  
  
 -- User canceled out.  
  
 end  
end  
  
local listener = function( event )  
 if media.hasSource( media.Camera ) then  
 local filePath = { baseDir = system.TemporaryDirectory, filename = "CameraShot.jpg" }  
 media.show( media.Camera, onComplete, filePath )  
 else  
 native.showAlert("Corona", "Camera not found.")  
 end  
 return true  
end  
  
local onbtnLoginEvent = function (event )  
 if event.phase == "release" then  
 print( "You pressed and released a button!" )  
 --native.showAlert( "Success", "The button was pressed!.", { "OK" } )  
 facebook.login( appId, fbListener, { "publish\_stream" } )  
 end  
end  
  
local onbtnCameraEvent = function (event )  
 if event.phase == "release" then  
 local filePath = { baseDir = system.TemporaryDirectory, filename = "CameraShot.jpg" }  
 media.show( media.Camera, onComplete, filePath )  
 end  
end  
  
local btnLogin = widget.newButton{  
 id = "btn001",  
 left = 100,  
 top = 200,  
 label = "Facebook Login",  
 width = 170, height = 28,  
 cornerRadius = 8,  
 onEvent = onbtnLoginEvent  
}  
  
btnLogin.x = 100  
btnLogin.y = 200  
  
local btnCamera = widget.newButton{  
 id = "btn002",  
 left = 100,  
 top = 400,  
 label = "Take Picture",  
 width = 170, height = 28,  
 cornerRadius = 8,  
 onEvent = onbtnCameraEvent  
}   
  
btnCamera.x = 100  
btnCamera.y = 400  

[import]uid: 184193 topic_id: 32551 reply_id: 130452[/import]

warrenwsav,

I remember facebook limiting the number of posts that I can do to someone’s page within an hour. I’ve seen this during testing. I’m not sure if facebook is supposed to do that (I haven’t found documentation about it) or if they were just filtering them out because the my posts were all the same. Or worse, flagging them as spam. In any case, I hope you don’t get bit by that too during testing. [import]uid: 32256 topic_id: 32551 reply_id: 130477[/import]

warrenwsav,

I remember facebook limiting the number of posts that I can do to someone’s page within an hour. I’ve seen this during testing. I’m not sure if facebook is supposed to do that (I haven’t found documentation about it) or if they were just filtering them out because the my posts were all the same. Or worse, flagging them as spam. In any case, I hope you don’t get bit by that too during testing. [import]uid: 32256 topic_id: 32551 reply_id: 130477[/import]

Thanks for the suggestion but that’s not it. I can run my app right now and it will post a text message. But when I try to send a picture it takes forever and says it was successfully uploaded but it’s not on my Facebook page. I have changed the filename, etc. I know the picture exists on the phone because I added code to show it right before the upload and it is there.

Anyone have any idea?

Thanks,

Warren
[import]uid: 184193 topic_id: 32551 reply_id: 130564[/import]

Thanks for the suggestion but that’s not it. I can run my app right now and it will post a text message. But when I try to send a picture it takes forever and says it was successfully uploaded but it’s not on my Facebook page. I have changed the filename, etc. I know the picture exists on the phone because I added code to show it right before the upload and it is there.

Anyone have any idea?

Thanks,

Warren
[import]uid: 184193 topic_id: 32551 reply_id: 130564[/import]

I recommend that you add some [lua]print()[/lua] statements to your code and make sure that you are actually making it to your [lua]facebook.request()[/lua] function call. You can view your print statements in the Android log via the Android SDK tools “adb logcat” or “ddms”. Also keep on the look out for any errors printed by facebook about your photo not getting uploaded. That’s as much as I can suggest at the moment. [import]uid: 32256 topic_id: 32551 reply_id: 130723[/import]

I recommend that you add some [lua]print()[/lua] statements to your code and make sure that you are actually making it to your [lua]facebook.request()[/lua] function call. You can view your print statements in the Android log via the Android SDK tools “adb logcat” or “ddms”. Also keep on the look out for any errors printed by facebook about your photo not getting uploaded. That’s as much as I can suggest at the moment. [import]uid: 32256 topic_id: 32551 reply_id: 130723[/import]

@Joshua,
Any chance the bug that I submitted a while back is going to get resolved anytime soon? Pretty much just waiting on that to release my app. [import]uid: 19620 topic_id: 32551 reply_id: 131639[/import]

@rxm - We’re taking photos, using display.save, emailing them, posting them to facebook, showing them onscreen, etc… on a galaxy s3 (4.0.1 I believe). We’re also passing the same images to a nexus 7, ipad, iphones, etc, and they look fantastic across all platforms. (wasn’t easy though)

Our content width and height is 640x960, and the app had squishing/distortion effects early on…

Images taken on some devices seemed stretched vertically, other stretched horizontally…

It turned out that there were some issues based on the apps content width/height related to the devices native resolution.

If you read the display.capture stuff carefully (the really really fine print), it says the capture stuff happens *in device pixels*… which you can compensate for easy enough (as long as you know of it).

Capturing at device pixel resolution made for some really really huge image grabbing on an ipad3, I tell ya – that had to be fixed too…

But then it got harder. When I took pictures on devices with native resolution that wasn’t as wide (or tall) as my content width/height, the display capture would just grab what it could.

But this left my image at an aspect ratio that was different than my intention (so a 640x960 intended capture, would be returned as a 540x960 capture – the best it could do on the device). Later, when the picture is displayed, my code would expand it to 640x960 and voila… It’s stretched…

It took a while (including dealing with landscape photos, etc) to get it all nice and perty, and our solutions are specific to what we’re doing, but some of this might be related (I relate all this because our images looked funky early on). [import]uid: 79933 topic_id: 32551 reply_id: 131645[/import]

@mpappas,
Thanks for sharing your experience with this. I set my own content width and height as well at the start of the project so that our app content would display well on any device possible. Its working great, but I just don’t see it as a solution to mess with our apps content area size at this point because we would have to redo almost everything in the app. our content size is a width of 320 by a height of 480. I thought that this would be a frequently used content size? isn’t that the size of the original iphone resolution? [import]uid: 19620 topic_id: 32551 reply_id: 131646[/import]

Didn’t read the entire thread but regarding Facebook, you should sandbox your app in the app settings page on Facebook. I learned that when I was playing around with facebook checkins. [import]uid: 13560 topic_id: 32551 reply_id: 131651[/import]

@rxm - there’s a lot of sizes these days, but a couple questions…

What size are the saved images? For things to not look squished/stretched, they need to be captured at the same ratio as your content dimensions, eg; 2:3 (320:480)

But come to think of it, one thing I didn’t consider is a content mode of zoom stretch (or any other mode that would stretch things one way or another).

If you’re doing a content stretch, then your likely to have a rough time getting your captured images to look nice on various devices… (I would steer away from that…)

Either way, you should check your saved image sizes on various devices, and consider the impact of displaying then on at your content resolution (and then, on top of that, factor in zoom stretching or any other mode like that you might be using).
[import]uid: 79933 topic_id: 32551 reply_id: 131656[/import]