Creating Facebook app for Android - quesiton

Hi,

I want to build an android app with corona sdk to login and post photos to Facebook. When creating an app on the Facebook developers page do I select Native Android App? If so what about the Class Name and Key Hashes? What do I do for that? I just need to know how to set it up on the Facebook side. I’ve read many pages on here but still need some help.

Thanks!

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

Yes, you create a class name. It’s the same as your app’s package name (i.e. com.yourcompany.yourapp)

As for the keyhash, go google keyhash and facebook. I don’t remember the syntax, but basically you run a command line tool to generate the keyhash. It will most likely be the wrong keyhash, but put it in anyway and try to login with your app. In the console log, facebook will tell you the keyhash it’s looking for, copy that keyhash and add it to your android settings and you are good to go. [import]uid: 19626 topic_id: 32551 reply_id: 129467[/import]

Have a look at the following blog posts. They explain how to set up your facebook developer page, how to retrieve the hash key for your app, and how to upload a photo.

http://www.coronalabs.com/blog/2012/07/25/faq-wednesday-your-facebook-questions/
http://www.coronalabs.com/blog/2011/12/16/uploading-photos-to-facebook-in-corona/
[import]uid: 32256 topic_id: 32551 reply_id: 129483[/import]

@joshua,
I am also in the middle of trying to make this work and had a question. Should we have to create our app in the facebook App center before our app and facebook can interact? I currently have entered all the required info on facebooks end such as the android hash, and all that info, but when I run my app and try to login I get "my app is misconfigured for Facebook login. Press Okay to go back to the application without connecting it to Facebook.

As a side note for the class name I have entered in “com.ansca.corona.CoronaActivity”, but according to robMiracle’s post above, should I instead be using my package name?

thanks [import]uid: 19620 topic_id: 32551 reply_id: 129485[/import]

rxmarccall,

You should create your app first and decide what the final package name is going to be. Then set up your facebook developer page.

You set “Android Package Name” to your app’s unique package name.

You set “Class Name” to “com.ansca.corona.CoronaActivity”. This is used to launch your app from facebook.

For the hash key, follow the FAQ that I posted a link to up above. The simplest solution is to attempt to log into facebook from your app with a “bad” hash key. It will fail, as expected, but the Android log will print the hash key that facebook was expecting. Copy and paste that hash key to your facebook developer page.

That FAQ also provides information that is relevant to both iOS and Android, such as how to set up your app to receive a token with an expiration of 60 days instead of the default few hour expiration. [import]uid: 32256 topic_id: 32551 reply_id: 129490[/import]

Yes, you create a class name. It’s the same as your app’s package name (i.e. com.yourcompany.yourapp)

As for the keyhash, go google keyhash and facebook. I don’t remember the syntax, but basically you run a command line tool to generate the keyhash. It will most likely be the wrong keyhash, but put it in anyway and try to login with your app. In the console log, facebook will tell you the keyhash it’s looking for, copy that keyhash and add it to your android settings and you are good to go. [import]uid: 19626 topic_id: 32551 reply_id: 129467[/import]

Hi, I was able to get the login dialog to popup on my app. So i got that far. Now I need to see how to upload a photo. I saw the code for it but I can’t figure out how to specify the folder on my android. Like what the baseDir would be for the Download folder or the camera pictures. Anyone know this?

After the login takes place I get a black screen. But I don’t have any other code anyways so that must be what happens huh?
[import]uid: 184193 topic_id: 32551 reply_id: 129511[/import]

Have a look at the following blog posts. They explain how to set up your facebook developer page, how to retrieve the hash key for your app, and how to upload a photo.

http://www.coronalabs.com/blog/2012/07/25/faq-wednesday-your-facebook-questions/
http://www.coronalabs.com/blog/2011/12/16/uploading-photos-to-facebook-in-corona/
[import]uid: 32256 topic_id: 32551 reply_id: 129483[/import]

@joshua,
I am also in the middle of trying to make this work and had a question. Should we have to create our app in the facebook App center before our app and facebook can interact? I currently have entered all the required info on facebooks end such as the android hash, and all that info, but when I run my app and try to login I get "my app is misconfigured for Facebook login. Press Okay to go back to the application without connecting it to Facebook.

As a side note for the class name I have entered in “com.ansca.corona.CoronaActivity”, but according to robMiracle’s post above, should I instead be using my package name?

thanks [import]uid: 19620 topic_id: 32551 reply_id: 129485[/import]

rxmarccall,

You should create your app first and decide what the final package name is going to be. Then set up your facebook developer page.

You set “Android Package Name” to your app’s unique package name.

You set “Class Name” to “com.ansca.corona.CoronaActivity”. This is used to launch your app from facebook.

For the hash key, follow the FAQ that I posted a link to up above. The simplest solution is to attempt to log into facebook from your app with a “bad” hash key. It will fail, as expected, but the Android log will print the hash key that facebook was expecting. Copy and paste that hash key to your facebook developer page.

That FAQ also provides information that is relevant to both iOS and Android, such as how to set up your app to receive a token with an expiration of 60 days instead of the default few hour expiration. [import]uid: 32256 topic_id: 32551 reply_id: 129490[/import]

Hi, I was able to get the login dialog to popup on my app. So i got that far. Now I need to see how to upload a photo. I saw the code for it but I can’t figure out how to specify the folder on my android. Like what the baseDir would be for the Download folder or the camera pictures. Anyone know this?

After the login takes place I get a black screen. But I don’t have any other code anyways so that must be what happens huh?
[import]uid: 184193 topic_id: 32551 reply_id: 129511[/import]

Please see the “Constants” section from the below API documentation. Those constant specify which directory you want to access.
http://docs.coronalabs.com/api/library/system/index.html
[import]uid: 32256 topic_id: 32551 reply_id: 129554[/import]

Thanks for this Joshua. I had no clue what to put there and I put my app’s package name in there and everything seems to work. If I use “com.ansca.corona.CoronaActivity” will that cause problems with multiple apps?

[import]uid: 19626 topic_id: 32551 reply_id: 129564[/import]

>> If I use “com.ansca.corona.CoronaActivity” will that cause problems with multiple apps?

No, because the “package name” you provide uniquely identifies your app.

The Android intent used to launch your app requires both a package name and the class type of the component to launch in its constructor, as documented here…
http://developer.android.com/reference/android/content/Intent.html#Intent(android.content.Context,%20java.lang.Class>)

And by the way, as of this week’s daily builds, Corona now supports launch arguments and the “applicationOpen” system events on Android. These features allow your app to support facebook deep linking. [import]uid: 32256 topic_id: 32551 reply_id: 129570[/import]

What is “facebook deep linking”? [import]uid: 19626 topic_id: 32551 reply_id: 129577[/import]

Please see the “Constants” section from the below API documentation. Those constant specify which directory you want to access.
http://docs.coronalabs.com/api/library/system/index.html
[import]uid: 32256 topic_id: 32551 reply_id: 129554[/import]

Here is facebook’s official documentation on deep linking…
http://developers.facebook.com/docs/mobile/android/deep_linking/

So, when the user taps on your app’s link in facebook, it will launch your app and pass the URL that the user tapped on as an argument. You can customize the URL with parameters to tell your app to display a particular screen or perform a particular operation. [import]uid: 32256 topic_id: 32551 reply_id: 129594[/import]

Thanks for this Joshua. I had no clue what to put there and I put my app’s package name in there and everything seems to work. If I use “com.ansca.corona.CoronaActivity” will that cause problems with multiple apps?

[import]uid: 19626 topic_id: 32551 reply_id: 129564[/import]

@Joshua,

I don’t know what else to do, I still get the “App Name is misconfigured for Facebook login”. In the facebook Developers do I need to actually publish my app so that its live on facebook?

There is a “Submit App Details” button, which I have not done yet because my app is not 100% finished [import]uid: 19620 topic_id: 32551 reply_id: 129596[/import]

I think you are setting up the wrong section on the facebook developer page.

You should be setting up your Android app in the “Settings\Basic” page. That’s where you set up your mobile app and obtain an app ID. There is only a “Save Changes” button at the bottom of that page. I believe that should be enough. [import]uid: 32256 topic_id: 32551 reply_id: 129597[/import]