0

내 탐색 창 응용 프로그램에서 Facebook을 로그인으로 통합하려고 시도하고 있습니다. Facebook 버튼을 클릭하면 로그인 할 수 있지만 로그인 후에는 나에게 이름, 이메일 및 그림을 보여주십시오.Android와 Facebook 통합에서 이름, 이메일 및 사진을 가져올 수 없습니다.

나는 이름, 이메일 및 그림을 얻는 데 다른 방법을 시도했지만 작동하지 않습니다. 그 중 하나는 Profile profileDefault = Profile.getCurrentProfile()을 "On Sucess"에 넣은 다음 profileDefault.getFirstName()을 실행하는 것이 었습니다.하지만 앱을 실행하고 로그인 한 후에 앱이 멈 추면.

getFaceBookProfileDetails 기능을 사용하면 로그인 할 수 있으며 앱은 계속 실행되지만 이름, 이메일 및 사진은 표시되지 않습니다. 빌드는이 탐색 서랍

의 내용 홈페이지 XML입니다 Gradle을

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "25.0.0" 
    defaultConfig { 
     applicationId "com.example.abdiel.culi" 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 
repositories { 
    mavenCentral() 
} 
dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.facebook.android:facebook-android-sdk:4.17.0' 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.android.support:support-v4:24.2.1' 
    testCompile 'junit:junit:4.12' 
} 

이 주 활동이 매니페스트

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.abdiel.culi"> 

    <uses-permission android:name="android.permission.INTERNET" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme.NoActionBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <meta-data 
      android:name="com.facebook.sdk.ApplicationId" 
      android:value="@string/facebook_app_id" /> 

     <activity 
      android:name="com.facebook.FacebookActivity" 
      android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" 
      android:label="@string/app_name" /> 

     <provider 
      android:name="com.facebook.FacebookContentProvider" 
      android:authorities="com.facebook.app.FacebookContentProvider442630429253125" 
      android:exported="true" /> 

     <activity android:name=".Recomendados_Activity"></activity> 
    </application> 

</manifest> 

이것은

package com.example.abdiel.culi; 

import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.support.design.widget.FloatingActionButton; 
import android.support.design.widget.Snackbar; 
import android.util.Log; 
import android.view.View; 
import android.support.design.widget.NavigationView; 
import android.support.v4.view.GravityCompat; 
import android.support.v4.widget.DrawerLayout; 
import android.support.v7.app.ActionBarDrawerToggle; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.widget.ImageView; 
import android.widget.TabHost; 
import android.widget.TextView; 

import com.facebook.AccessToken; 
import com.facebook.AccessTokenTracker; 
import com.facebook.FacebookSdk; 
import com.facebook.Profile; 
import com.facebook.ProfileTracker; 
import com.facebook.appevents.AppEventsLogger; 
import com.facebook.CallbackManager; 
import com.facebook.FacebookCallback; 
import com.facebook.FacebookException; 
import com.facebook.login.LoginManager; 
import com.facebook.login.LoginResult; 
import com.facebook.login.widget.LoginButton; 
import com.squareup.picasso.Picasso; 
import com.facebook.GraphRequest; 
import com.facebook.GraphResponse; 
import org.json.JSONObject; 
import android.widget.TabHost; 
import android.widget.TabHost.TabSpec; 
import android.support.v4.app.FragmentTabHost; 
import static android.view.View.INVISIBLE; 
import static com.example.abdiel.culi.R.id.imageviewFotoPerfil; 

public class MainActivity extends AppCompatActivity 
     implements NavigationView.OnNavigationItemSelectedListener { 

    private CallbackManager callbackManager; 
    // private AccessTokenTracker accessTokenTracker; 
    // private ProfileTracker profileTracker; 

    LoginButton buttonLoginFacebook; 
    TextView textViewName, textViewEmail; 
    ImageView imageViewPhoto; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     FacebookSdk.sdkInitialize(getApplicationContext()); 
     AppEventsLogger.activateApp(this); 
     callbackManager = CallbackManager.Factory.create(); 


     setContentView(R.layout.activity_main); 
     textViewName = (TextView) findViewById(R.id.textviewNombre); 
     buttonLoginFacebook = (LoginButton) findViewById(R.id.login_button); 
     textViewEmail = (TextView) findViewById(R.id.textviewEmail); 
     buttonLoginFacebook.setReadPermissions("email"); 
     imageViewPhoto = (ImageView) findViewById(R.id.imageviewFotoPerfil); 


     buttonLoginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { 
      @Override 
      public void onSuccess(LoginResult loginResult) { 

       //Método usado para obtener los campos o atributos solciitados 
       getFaceBookProfileDetails(loginResult.getAccessToken()); 
       //buttonLoginFacebook.setVisibility(View.GONE); 

      } 

      @Override 
      public void onCancel() { 

      } 

      @Override 
      public void onError(FacebookException error) { 

      } 
     }); 



     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 

     FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 
     fab.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 
         .setAction("Action", null).show(); 
      } 
     }); 

     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
       this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
     drawer.setDrawerListener(toggle); 
     toggle.syncState(); 

     NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 
     navigationView.setNavigationItemSelectedListener(this); 
    } 

    @Override 
    public void onBackPressed() { 
     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     if (drawer.isDrawerOpen(GravityCompat.START)) { 
      drawer.closeDrawer(GravityCompat.START); 
     } else { 
      super.onBackPressed(); 
     } 
    } 
    private void getFaceBookProfileDetails(final AccessToken accessToken) { 

     GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() { 

      @Override 
      public void onCompleted(final JSONObject object, GraphResponse response) { 
       try { 
        //Profile clase que contiene las características báscias de la cuenta de facebook (No retorna email) 
        Profile profileDefault = Profile.getCurrentProfile(); 
        //Librería usada para poder mostrar la foto de perfil de facebook con una transformación circular 
        Picasso.with(MainActivity.this).load(profileDefault.getProfilePictureUri(100,100)).transform(new CircleTransform()).into(imageViewPhoto); 
        textViewName.setText(profileDefault.getFirstName()); 
        textViewEmail.setText(object.getString("email")); 
       } catch (Exception e) { 
        Log.e("E-MainActivity", "getFaceBook" + e.toString()); 
       } 
      } 
     }); 
     Bundle parameters = new Bundle(); 
     //solicitando el campo email 
     parameters.putString("fields", "email"); 
     request.setParameters(parameters); 
     request.executeAsync(); 
    } 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     //Retorna la reppuesta después del ingreso de las credenciales de facebook 
     callbackManager.onActivityResult(requestCode, resultCode, data); 
    } 

    @Override 
    protected void onResume() { 
     super.onResume(); 

     // Logs 'install' and 'app activate' App Events. 
     AppEventsLogger.activateApp(this); 
    } 

    @Override 
    protected void onPause() { 
     super.onPause(); 

     // Logs 'app deactivate' App Event. 
     AppEventsLogger.deactivateApp(this); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     // Handle action bar item clicks here. The action bar will 
     // automatically handle clicks on the Home/Up button, so long 
     // as you specify a parent activity in AndroidManifest.xml. 
     int id = item.getItemId(); 

     //noinspection SimplifiableIfStatement 
     if (id == R.id.action_settings) { 
      return true; 
     } 

     return super.onOptionsItemSelected(item); 
    } 

    @SuppressWarnings("StatementWithEmptyBody") 
    @Override 
    public boolean onNavigationItemSelected(MenuItem item) { 
     // Handle navigation view item clicks here. 
     int id = item.getItemId(); 

     if (id == R.id.itemBusqueda) { 
      // Handle the camera action 
     } else if (id == R.id.nav_gallery) { 

     } else if (id == R.id.nav_slideshow) { 

     } else if (id == R.id.nav_manage) { 

     } else if (id == R.id.nav_share) { 

     } else if (id == R.id.nav_send) { 

     } 

     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     drawer.closeDrawer(GravityCompat.START); 
     return true; 
    } 
} 

에게이다

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.example.abdiel.culi.MainActivity" 
    tools:showIn="@layout/app_bar_main"> 

    <TextView 
     android:id="@+id/textviewEmail" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" /> 

    <com.facebook.login.widget.LoginButton 
     android:id="@+id/login_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     /> 

</RelativeLayout> 

이 나는 ​​또한 답변의 단계에 따라이 코드를 시도 탐색 서랍

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

    <include 
     layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer" /> 

</android.support.v4.widget.DrawerLayout> 

의 활동의 주요 XML하지만 난이 응용 프로그램을 실행할 때 정지합니다.

public class MainActivity extends AppCompatActivity 
     implements NavigationView.OnNavigationItemSelectedListener { 

    private CallbackManager callbackManager; 
    private AccessTokenTracker accessTokenTracker; 
    // private ProfileTracker profileTracker; 

    Profile profile; 
    private ProfileTracker mProfileTracker; 

    LoginButton buttonLoginFacebook; 
    TextView textViewName, textViewEmail; 
    ImageView imageViewPhoto; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 


     AppEventsLogger.activateApp(this); 

     FacebookSdk.sdkInitialize(getApplicationContext()); 
     callbackManager = CallbackManager.Factory.create(); 
     updateWithToken(AccessToken.getCurrentAccessToken()); 
     accessTokenTracker = new AccessTokenTracker() { 
      @Override 
      protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) { 
       updateWithToken(newToken); 
      } 
     }; 
     accessTokenTracker.startTracking(); 

     buttonLoginFacebook = (LoginButton) findViewById(R.id.login_button); 
     buttonLoginFacebook.setReadPermissions(Arrays.asList(
       "public_profile", "email", "user_friends")); 
     //buttonLoginFacebook.registerCallback(callbackManager,callback); 
     buttonLoginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { 
        @Override 
        public void onSuccess(LoginResult loginResult) { 
         try { 
          if (Profile.getCurrentProfile() == null) { 
           mProfileTracker = new ProfileTracker() { 
            @Override 
            protected void onCurrentProfileChanged(Profile profile_old, Profile profile_new) { 
             // profile2 is the new profile 
             profile = profile_new; 
             mProfileTracker.stopTracking(); 
            } 
           }; 
           mProfileTracker.startTracking(); 
          } else { 
           profile = Profile.getCurrentProfile(); 
           Log.v("facebook - profile", profile.getFirstName()); 
          } 

          GraphRequest request = GraphRequest.newMeRequest(
            loginResult.getAccessToken(), 
            new GraphRequest.GraphJSONObjectCallback() { 
             @Override 
             public void onCompleted(JSONObject object, GraphResponse response) { 
              Log.v("FACEBOOK LOGIN", response.toString()); 
              // Application code 
              try { 
               //Profile clase que contiene las características báscias de la cuenta de facebook (No retorna email) 
               Profile profileDefault = Profile.getCurrentProfile(); 
               //Librería usada para poder mostrar la foto de perfil de facebook con una transformación circular 
               Picasso.with(MainActivity.this).load(profileDefault.getProfilePictureUri(100,100)).transform(new CircleTransform()).into(imageViewPhoto); 
               textViewName.setText(profileDefault.getFirstName()); 
               textViewEmail.setText(object.getString("email")); 
              } catch (JSONException e) { 
               e.printStackTrace(); 
              } 
              //show facebook data in your activity 
             } 
            }); 
          Bundle parameters = new Bundle(); 
          parameters.putString("fields", "name,email,picture"); 
          request.setParameters(parameters); 
          request.executeAsync(); 
         } catch (Exception e) { 
          Log.d("ERROR", e.toString()); 
         } 
        } 

        @Override 
        public void onCancel() { 

        } 

        @Override 
        public void onError(FacebookException e) { 
         Log.d("FACEBOOK ERRROR", e.toString()); 

        } 
       }); 




     setContentView(R.layout.activity_main); 
     textViewName = (TextView) findViewById(R.id.textviewNombre); 

     textViewEmail = (TextView) findViewById(R.id.textviewEmail); 

     imageViewPhoto = (ImageView) findViewById(R.id.imageviewFotoPerfil); 




     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 

     FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 
     fab.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 
         .setAction("Action", null).show(); 
      } 
     }); 

     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
       this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
     drawer.setDrawerListener(toggle); 
     toggle.syncState(); 

     NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 
     navigationView.setNavigationItemSelectedListener(this); 
    } 

    @Override 
    public void onBackPressed() { 
     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     if (drawer.isDrawerOpen(GravityCompat.START)) { 
      drawer.closeDrawer(GravityCompat.START); 
     } else { 
      super.onBackPressed(); 
     } 
    } 



    private void updateWithToken(AccessToken currentAccessToken) { 

     if (currentAccessToken != null) { 
      //User logged In--do your stuff 
      //log out user first 
      LoginManager.getInstance().logOut(); 
     } else { 
      //user not logged in 
     } 
    } 


    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     //Retorna la reppuesta después del ingreso de las credenciales de facebook 
     callbackManager.onActivityResult(requestCode, resultCode, data); 
    } 

    @Override 
    protected void onResume() { 
     super.onResume(); 

     // Logs 'install' and 'app activate' App Events. 
     AppEventsLogger.activateApp(this); 
    } 

    @Override 
    protected void onPause() { 
     super.onPause(); 

     // Logs 'app deactivate' App Event. 
     AppEventsLogger.deactivateApp(this); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     // Handle action bar item clicks here. The action bar will 
     // automatically handle clicks on the Home/Up button, so long 
     // as you specify a parent activity in AndroidManifest.xml. 
     int id = item.getItemId(); 

     //noinspection SimplifiableIfStatement 
     if (id == R.id.action_settings) { 
      return true; 
     } 

     return super.onOptionsItemSelected(item); 
    } 

    @SuppressWarnings("StatementWithEmptyBody") 
    @Override 
    public boolean onNavigationItemSelected(MenuItem item) { 
     // Handle navigation view item clicks here. 
     int id = item.getItemId(); 

     if (id == R.id.itemBusqueda) { 
      // Handle the camera action 
     } else if (id == R.id.nav_gallery) { 

     } else if (id == R.id.nav_slideshow) { 

     } else if (id == R.id.nav_manage) { 

     } else if (id == R.id.nav_share) { 

     } else if (id == R.id.nav_send) { 

     } 

     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     drawer.closeDrawer(GravityCompat.START); 
     return true; 
    } 
} 

답변

0

manageCallBackOfFacebook() 메서드를 하나 생성하거나 직접 콜백 코드를 입력하십시오. 당신의 페이스 북 콜백을 액티비티 클래스에서 처리하십시오.

가에서 onCreate()하여 updateWithToken에

FacebookSdk.sdkInitialize(getApplicationContext()); 
    callbackManager = CallbackManager.Factory.create(); 
    updateWithToken(AccessToken.getCurrentAccessToken()); 
    accessTokenTracker = new AccessTokenTracker() { 
     @Override 
     protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) { 
      updateWithToken(newToken); 
     } 
    }; 
    accessTokenTracker.startTracking(); 

    loginButton = (LoginButton) findViewById(R.id.login_button); 
    loginButton.setReadPermissions(Arrays.asList(
      "public_profile", "email", "user_friends")); 
    loginButton.registerCallback(callbackManager, callback); 

에서

Profile profile; 
private ProfileTracker mProfileTracker; 

선언

public class LoginActivity extends AppCompatActivity 
{ 

    private CallbackManager callbackManager; 
    private AccessTokenTracker accessTokenTracker; 
    private ProfileTracker profileTracker; 

    @Override 
    protected void onCreate(Bundle savedInstanceState){ 
     super.onCreate(savedInstanceState); 
     //initialize facebook Sdk 
     FacebookSdk.sdkInitialize(getApplicationContext()); 
     manageCallBackOfFacebook(); 
     callbackManager = CallbackManager.Factory.create(); 

     setContentView(); 
     ... 
    } 

    private void manageCallBackOfFacebook() 
    { 
     try 
     { 
      callbackManager = CallbackManager.Factory.create(); 
      accessTokenTracker = new AccessTokenTracker() { 
       @Override 
       protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) { 

       } 
      }; 

      profileTracker = new ProfileTracker() 
      { 
       @Override 
       protected void onCurrentProfileChanged(Profile oldProfile, Profile newProfile) 
       { 
        if (newProfile != null) 
        { 
         Log.i(TAG +" getName ", newProfile.getName());""+newProfile.getLinkUri()); 
         Log.i(TAG +" getProfilePictureUri", ""+newProfile.getProfilePictureUri(200, 150)); 
        } 
       } 
      }; 

      accessTokenTracker.startTracking(); 
      profileTracker.startTracking(); 
     }catch (Exception e){ 
      e.printStackTrace(); 
     } 
    } 
} 
+0

? "On create"또는 "On success"에 넣어야합니까? 좀 더 구체적인 단계별로하십시오. 내 코드를 살펴보고 주요 활동의 전체 코드를 보여줄 수 있다면 나는 그것을 사과 할 것이다. Im android studio에서 새로 생겼습니다. 감사합니다 – Pierre

+0

내 업데이트 된 답변을 확인하시기 바랍니다. – Shailesh

+0

작동하지 않습니다. Facebook 버튼을 클릭하면 앱이 중지됩니다. 나는 너의 계단을 따랐다. 어떠한 제안? 나는 이것을 알아낼 필요가있다. – Pierre

0

이 변경 시도 ..() 메소드

private void updateWithToken(AccessToken currentAccessToken) { 

    if (currentAccessToken != null) { 
     //User logged In--do your stuff 
     //log out user first 
     LoginManager.getInstance().logOut(); 
    } else { 
     //user not logged in 
     } 
    } 
콜백 방법또한

활동에이 -add 나는 방법 manageCallBackOfFacebook()를 넣어해야

private FacebookCallback<LoginResult> callback = new FacebookCallback<LoginResult>() { 

    @Override 
    public void onSuccess(LoginResult loginResult) { 
     try { 
      if (Profile.getCurrentProfile() == null) { 
       mProfileTracker = new ProfileTracker() { 
        @Override 
        protected void onCurrentProfileChanged(Profile profile_old, Profile profile_new) { 
         // profile2 is the new profile 
         profile = profile_new; 
         mProfileTracker.stopTracking(); 
        } 
       }; 
       mProfileTracker.startTracking(); 
      } else { 
       profile = Profile.getCurrentProfile(); 
       Log.v("facebook - profile", profile.getFirstName()); 
      } 

      GraphRequest request = GraphRequest.newMeRequest(
        loginResult.getAccessToken(), 
        new GraphRequest.GraphJSONObjectCallback() { 
         @Override 
         public void onCompleted(JSONObject object, GraphResponse response) { 
          Log.v("FACEBOOK LOGIN", response.toString()); 
          // Application code 
          try { 
           fb_id = object.getString("id"); 
           fb_name = object.getString("name"); 
           profilePicUrl = "https://graph.facebook.com/" + fb_id + "/picture?width=200&height=200"; 
           fb_email = object.getString("email"); 
          } catch (JSONException e) { 
           e.printStackTrace(); 
          } 
          //show facebook data in your activity 
         } 
        }); 
      Bundle parameters = new Bundle(); 
      parameters.putString("fields", "id,name,email,picture.type(small)"); 
      request.setParameters(parameters); 
      request.executeAsync(); 
     } catch (Exception e) { 
      Log.d("ERROR", e.toString()); 
     } 
    } 

    @Override 
    public void onCancel() { 

    } 

    @Override 
    public void onError(FacebookException e) { 
     Log.d("FACEBOOK ERRROR", e.toString()); 
    } 
}; 
+0

나는 그것을한다. 내가 앱을 실행할 때 멈춘다. 앱을 시작하지도 않습니다. – Pierre

+0

내가 로그캣 오류를 표시 할 수 있습니까? – rafsanahmad007

+0

12-20 02 : 56 : 23.693 14853-14883 /? D/NativeCrypto : ssl = 0x518071a0 sslRead buf = 0x4153c9c8 len = 1, timeo = 0 12-20 02 : 56 : 23.693 14853-14883 /?D/NativeCrypto : SSL_Read() ssl = 0x518071a0, appData = 0x50190d80 12-20 02 : 56 : 23.693 14853-14883 /? D/NativeCrypto : 결과 1, 오류 코드 0, SSL_Read()에서 반환 됨 ssl = 0x518071a0, appData = 0x50190d80 – Pierre