0

I want to fetch information form facebook i know it can be done by using facebook sdk easily but I have a list using intent chooser and from that popup if user click on facebook and they are already logged in, from there I want to fetch user information, form device I want to fetch information.how to do that? EDIT I already get user email id from account manager but i want user name as well how to retrive that?

Edit

         AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE);
          Account[] list = manager.getAccounts();

    Log.v("tag", "data is "+list);

    String possibleEmail="";

       try{
               possibleEmail += " Gmail Account \n\n";
               Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");

               for (Account account : accounts) {

                 possibleEmail += " - "+account.name+" : "+account.type+" , \n";
                 possibleEmail += " \n\n";

               }
          }
          catch(Exception e)
          {
               Log.i("Exception", "Exception:"+e) ; 
          }


          try{
               possibleEmail += "All Accounts \n\n";

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

                  possibleEmail += " - "+account.name+" : "+account.type+" , \n";
                  possibleEmail += " \n";

               }
          }
          catch(Exception e)
          {
               Log.i("Exception", "Exception:"+e) ; 
          }

       // Show on screen    
       accountsData.setText(possibleEmail);

       Log.i("Exception", "mails:"+possibleEmail) ;
}

from this code i am able to get user id of all accounts but it is giving only id's i tried for user name but it's not working with that.any one can help me with this?

Randroid
  • 3,688
  • 5
  • 30
  • 55
Apurva Agrawal
  • 259
  • 2
  • 13
  • check this http://stackoverflow.com/questions/5513150/android-facebook-get-all-profile-information – Randroid Aug 01 '14 at 11:39
  • Thanks for your comment but i don't want to use facebook sdk, i have to fetch user information from device (information of the4 user who is already logged in on facebook) – Apurva Agrawal Aug 01 '14 at 11:47
  • If you have done something why dont you post the code so that people will look in to that to give a quick response :) – Randroid Aug 01 '14 at 11:58
  • @Raghu I have edited my question, please go through that may be you will get a better idea about my code and problem. – Apurva Agrawal Aug 01 '14 at 12:06
  • I dont think u can get the FB info without using FB sdk.please read the docs once.You have to make a request to the get the GraphUser-Object. With this object you can get the informations you want: GraphUser user.getName(); ,user.getId(); etc. – Randroid Aug 01 '14 at 12:25
  • @Raghu ok I can get information for facebook but what about twitter and Gplus Pinterest? Do you have any idea? – Apurva Agrawal Aug 04 '14 at 06:30

1 Answers1

0

As per my understanding you can achieve those two functionalities by this way.

For twitter you should use twitter4j-core-android2.2.3.jar and here is the code snippet to get the user information

    accessToken = twitterConnection.getOAuthAccessToken
(requestToken,editPinCode.getText().toString());

 oHelper.storeAccessToken(accessToken);

Log.i("Access Token:", accessToken.getToken());

Log.i("Access Secret:", accessToken.getTokenSecret());

long userID = accessToken.getUserId();

User user = twitterConnection.showUser(userID);

 user.getName();

and for gplus integration & implementation just follow this tutorial

http://ankitthakkar90.blogspot.in/2013/05/google-plus-integration-in-android.html https://developers.google.com/+/mobile/android/people

code snippet is here

Use the Plus.PeopleApi.getCurrentPerson method to request profile information the currently signed in user.

You can call the getCurrentPerson method after the GoogleApiClient is connected:

@Override
public void onConnected() {
 ...
    if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
    Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
    String personName = currentPerson.getDisplayName();
    String personPhoto = currentPerson.getImage();
    String personGooglePlusProfile = currentPerson.getUrl();
  }
  }
Randroid
  • 3,688
  • 5
  • 30
  • 55