Question

I want to get the facebook ID of an Android Account. If it's possible, would like to use the Facebook SDK to do some things like posting on the wall.

How can i get the informations from the AndroidAccounts ?

Currently i can get my Gmail address with the accoutManager.

Thanks

Was it helpful?

Solution

If you want your app to do something in the facebook of the user you need his authorization. You need to use the Facebook API because your app needs to ask for permissions from the user. Here's a link for the Facebook API: https://developers.facebook.com/docs/mobile/android/build/

If you have any further questions, feel free to ask.

OTHER TIPS

How are you getting your gmail account address? AccountManager.getAccountsByType("com.google")? If you are getting your gmail account, you can also get your facebook account via the AccountManager class if it is on the device, just change your code to:

Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account: accounts) {
   String accountEmail = account.name;
}

And then debug. If your facebook account is listed under the synced accounts on the device, (Menu > Settings > Accounts & Sync) it should appear in this Account array. You could then restrict the method to use AccountManager's getAccountsByType method, which will accept whatever type the facebook account is as a String value (probably something like "com.facebook") to retrieve your facebook account ID.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top